XafApplication Class
Manages an XAF application.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.1.dll
NuGet Package: DevExpress.ExpressApp
#Declaration
#Remarks
The XafApplication
class contains methods to create Controllers, Views, Object Space (see BaseObjectSpace), and other XAF elements. Its properties specify application name and title, configuration string, provide access to the Application Model, modules and the strategy that manages View visibility. You can customize many built-in mechanisms to manage your application. For this purpose, use XafApplication
‘s events.
XAF creates and initializes a XafApplication
descendant as follows:
Platform | Created and Initialized | File |
---|---|---|
ASP. |
When IXaf is called for the first time (usually when XAF initializes the page). |
Startup. |
Windows Forms | In the Main method. |
Program. |
ASP. |
When a session starts. | Global. |
Application Server | In the Application constructor. |
Application |
Backend Web API Service / REST API | Only during initialization. | Startup. |
Note
Xaf
is not available in Web API Service endpoints. XAF creates it on service initialization only for compatibility check and localization services setup.
To configure your application, use Application Builder.
#Usage Considerations
XafApplication
is essential for an application’s initial setup (for example, to set up modules and gather TypesInfo
). However, after this initial setup, some services can function independently of XafApplication
. We recommend that you use the APIs provided by these services instead of the XafApplication
API for the same tasks because events and methods within XafApplication
may not trigger if the corresponding operation occurs outside its context.
For example, if you subscribe to the XafApplication.ObjectSpaceCreated event, it is not guaranteed to fire because it is possible to create IObjectSpace
outside of XafApplication
. To handle occurrences when an IObjectSpace
is created use the ObjectSpaceProviderEvents.OnObjectSpaceCreated method.
As another important example, you need to keep in mind that the XafApplication.LoggedOn does not fire every time that a user is logged in by the Security System. For instance, the event does not fire in the following cases:
- When a request to load data for a Dashboard or Report is processed.
- When Web API Service handles a request, it disposes of its
XafApplication
instance after the initial setup is completed. After that, you can only use services. See the following topic for information on how to access these services: Access Object Space, Security System, and Caption Helper in Custom Endpoint Methods.
For more information and examples, refer to the following ticket: Core - ValueManager API availability and deprecated static helpers in XAF .NET 6+ apps (Blazor, Web API Service, WinForms).