Model Differences Store

Introduction

Сustomizations of the Application Model are called Application Model Differences ( or User Model Differences). XAF provides a different ways to store Model Differences. If you need to store Model Differences in a custom resource, implement your own storage by inheriting from the DevExpress.ExpressApp.ModelDifferenceStore abstract class. To make the system use your storage, handle the following events:

Xafari has expanded described mechanism in the following ways:

WinApplication and WebApplication classes don't provides public methods to create storage. In the code of your module you can not receive what type of storage is currently in use in the application. The demand task is to create in your module a correct instance of the storage, i.e. storage type in your module should automatically be equal to the storage type in the application. Such a module could be guaranteed to work with any application (Win, Web etc.).

No way to get the current instance of the storage used in the application.

Default implementation of the store does not share User Model Differences for different users of the system.

Xafari Model Differences storage: how it works

This mechanism is used in the Xafari framework by default. Basics of the Model Differences storage support in Xafari is provided by the Xafari.dll assembly (see Classes).

Xafari.Win.dll assembly contains Xafari Win Module to manage Windows Forms applications. Xafari Win Module initializes the Model Differences storage management system, it sets the File Store by creating an instance of the FileUserModelDifferenceStoreFactory in the Setup method of the XafariWinModule class.

  • c#
  • VB

public override void Setup(XafApplication application)
{
  ModelDifferenceStoreManager.Instance.ModelDifferenceStoreFactory = new FileUserModelDifferenceStoreFactory(modelDifferenceFilePath, userModelDifferenceFilePath);
}

Public Overrides Sub Setup(ByVal application As XafApplication)
  ModelDifferenceStoreManager.Instance.ModelDifferenceStoreFactory = New FileUserModelDifferenceStoreFactory(modelDifferenceFilePath, userModelDifferenceFilePath)
End Sub

From this moment the application uses FileUserModelDifferenceStore storage. In contrast to the implementation of the DevExpress, this storage stores the User Model Differences for each user, in addition, it allows you to enter additional layers. For example, the Workpkaces mechanism adds an additional layer - the Workplace. Model Differences are stored separately for each Workplace and each user.

Xafari.Web.dll assembly contains Xafari Web Module to manage ASP.NET applications. Xafari Web Module initializes the Model Differences storage management system, it sets the Cookies Store by creating an instance of the SessionUserModelDifferenceStoreFactory in the Setup method of the XafariWebModule class.

  • c#
  • VB

public override void Setup(XafApplication application)
{
  ModelDifferenceStoreManager.Instance.ModelDifferenceStoreFactory = new SessionUserModelDifferenceStoreFactory();
}

Public Overrides Sub Setup(ByVal application As XafApplication)
  ModelDifferenceStoreManager.Instance.ModelDifferenceStoreFactory = New SessionUserModelDifferenceStoreFactory()
End Sub

From this moment the application uses SessionUserModelDifferenceStore storage, which operates similarly to the FileUserModelDifferenceStore.

When developing your projects you can use your own types of storage. For this it is necessary to create a factory class and initialize them in Store Manager, similar to that in the above examples.

This approach is utilized by the Northwind DC Win demo application installed with Xafari. By default, the Northwind DC application is installed in %PUBLIC%\Documents\Xafari Framework vXX.X.XXXX Demos\Northwind.DC. Examine ModelDifferenceAspect table of the application's database.

Learn more: