Example

The code snippet below demonstrates the AppModule implemented in the Northwind demo application:

  • c#
  • VB

public sealed partial class NorthwindAppModule : ModuleBase, ISecurityStrategyProvider
{
  private DevExpress.ExpressApp.Security.SecurityStrategyComplex securityStrategyComplex;
  private Xafari.Security.XafariAuthentication xafariAuthentication;
  public NorthwindAppModule()
  {
    this.xafariAuthentication = new XafariAuthentication();
    InitializeComponent();
    this.xafariAuthentication.AuthenticationActiveDirectory.CreateUserAutomatically = true;
    this.xafariAuthentication.AuthenticationActiveDirectory.LogonParametersType = typeof(Xafari.Security.XafariAuthenticationLogonParameters);
    this.xafariAuthentication.AuthenticationStandard.LogonParametersType = typeof(Xafari.Security.XafariAuthenticationLogonParameters);
    this.xafariAuthentication.LogonParametersType = typeof(Xafari.Security.XafariAuthenticationLogonParameters);
    this.securityStrategyComplex = new SecurityStrategyComplex();
    this.securityStrategyComplex.Authentication = this.xafariAuthentication;
    this.securityStrategyComplex.RoleType = typeof(Xafari.Northwind.Security.InheritedRole);
    this.securityStrategyComplex.UserType = typeof(Xafari.Northwind.Security.InheritedUser);
  }
  public override void Setup(XafApplication application)
  {
    base.Setup(application);
    application.Security = this.securityStrategyComplex;
    application.ApplicationName = "Xafari.Northwind";
    application.CreateCustomObjectSpaceProvider += (sender, e) =>
    {
      e.ObjectSpaceProvider = new XPObjectSpaceProvider(e.ConnectionString, e.Connection);
    };
  }
  public SecurityStrategy GetSecurityStrategy()
  {
    return this.securityStrategyComplex;
  }
  private void InitializeComponent()
  {
    this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.SystemModule.SystemModule));
    this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.Security.SecurityModule));
    this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.Validation.ValidationModule));
    this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.CloneObject.CloneObjectModule));
    this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.ConditionalAppearance.ConditionalAppearanceModule));
    this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.ViewVariantsModule.ViewVariantsModule));
    this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.TreeListEditors.TreeListEditorsModuleBase));
    this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.ScriptRecorder.ScriptRecorderModuleBase));
    this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.Reports.ReportsModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.XafariModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.Arms.XafariArmsModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.Security.XafariSecurityModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.ManagedOperations.XafariManagedOperationsModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.BC.Numerators.XafariBCNumeratorsModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.BC.Numerators.Xpo.XafariBCNumeratorsXpoModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.Editors.XafariEditorsModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.BC.XafariBCModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.BC.Xpo.XafariBCXpoModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.Reports.XafariReportsModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.Workplace.XafariWorkplaceModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.Northwind.NorthwindModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.Northwind.Commands.CommandsModule));
    this.RequiredModuleTypes.Add(typeof(Xafari.Security.Xpo.XafariSecurityXpoModule));
  }
}

Public Partial NotInheritable Class NorthwindAppModule
  Inherits ModuleBase
  Implements ISecurityStrategyProvider
  Private _securityStrategyComplex As DevExpress.ExpressApp.Security.SecurityStrategyComplex
  Private _xafariAuthentication As Xafari.Security.XafariAuthentication
  Public Sub New()
    Me._xafariAuthentication = New XafariAuthentication()
    InitializeComponent()
    Me._xafariAuthentication.AuthenticationActiveDirectory.CreateUserAutomatically = True
    Me._xafariAuthentication.AuthenticationActiveDirectory.LogonParametersType = GetType(Xafari.Security.XafariAuthenticationLogonParameters)
    Me._xafariAuthentication.AuthenticationStandard.LogonParametersType = GetType(Xafari.Security.XafariAuthenticationLogonParameters)
    Me._xafariAuthentication.LogonParametersType = GetType(Xafari.Security.XafariAuthenticationLogonParameters)
    Me._securityStrategyComplex = New SecurityStrategyComplex()
    Me._securityStrategyComplex.Authentication = Me._xafariAuthentication
    Me._securityStrategyComplex.RoleType = GetType(Xafari.Northwind.Security.InheritedRole)
    Me._securityStrategyComplex.UserType = GetType(Xafari.Northwind.Security.InheritedUser)
  End Sub
  Public Overrides Sub Setup(ByVal application As XafApplication)
    MyBase.Setup(application)
    application.Security = Me._securityStrategyComplex
    application.ApplicationName = "Xafari.Northwind"
    application.CreateCustomObjectSpaceProvider += Sub(ByVal sender, ByVal e)
      e.ObjectSpaceProvider = New XPObjectSpaceProvider(e.ConnectionString, e.Connection)
    End Sub
  End Sub
  Public Function GetSecurityStrategy() As SecurityStrategy
    Return Me._securityStrategyComplex
  End Function
  Private Sub InitializeComponent()
    Me.RequiredModuleTypes.Add(GetType(DevExpress.ExpressApp.SystemModule.SystemModule))
    Me.RequiredModuleTypes.Add(GetType(DevExpress.ExpressApp.Security.SecurityModule))
    Me.RequiredModuleTypes.Add(GetType(DevExpress.ExpressApp.Validation.ValidationModule))
    Me.RequiredModuleTypes.Add(GetType(DevExpress.ExpressApp.CloneObject.CloneObjectModule))
    Me.RequiredModuleTypes.Add(GetType(DevExpress.ExpressApp.ConditionalAppearance.ConditionalAppearanceModule))
    Me.RequiredModuleTypes.Add(GetType(DevExpress.ExpressApp.ViewVariantsModule.ViewVariantsModule))
    Me.RequiredModuleTypes.Add(GetType(DevExpress.ExpressApp.TreeListEditors.TreeListEditorsModuleBase))
    Me.RequiredModuleTypes.Add(GetType(DevExpress.ExpressApp.ScriptRecorder.ScriptRecorderModuleBase))
    Me.RequiredModuleTypes.Add(GetType(DevExpress.ExpressApp.Reports.ReportsModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.XafariModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.Arms.XafariArmsModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.Security.XafariSecurityModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.ManagedOperations.XafariManagedOperationsModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.BC.Numerators.XafariBCNumeratorsModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.BC.Numerators.Xpo.XafariBCNumeratorsXpoModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.Editors.XafariEditorsModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.BC.XafariBCModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.BC.Xpo.XafariBCXpoModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.Reports.XafariReportsModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.Workplace.XafariWorkplaceModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.Northwind.NorthwindModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.Northwind.Commands.CommandsModule))
    Me.RequiredModuleTypes.Add(GetType(Xafari.Security.Xpo.XafariSecurityXpoModule))
  End Sub
End Class

appmodule_3