-
Notifications
You must be signed in to change notification settings - Fork 1
/
Module.cs
60 lines (59 loc) · 2.82 KB
/
Module.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Text;
using System.Linq;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.ExpressApp.DC;
using System.Collections.Generic;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.BaseImpl.PermissionPolicy;
using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Updating;
using DevExpress.ExpressApp.Model.Core;
using DevExpress.ExpressApp.Model.DomainLogics;
using DevExpress.ExpressApp.Model.NodeGenerators;
using DevExpress.ExpressApp.Xpo;
using NonPersistentObjectsDemo.Module.BusinessObjects;
namespace NonPersistentObjectsDemo.Module {
// For more typical usage scenarios, be sure to check out https://docs.devexpress.com/eXpressAppFramework/DevExpress.ExpressApp.ModuleBase.
public sealed partial class NonPersistentObjectsDemoModule : ModuleBase {
public NonPersistentObjectsDemoModule() {
InitializeComponent();
BaseObject.OidInitializationMode = OidInitializationMode.AfterConstruction;
}
public override IEnumerable<ModuleUpdater> GetModuleUpdaters(IObjectSpace objectSpace, Version versionFromDB) {
ModuleUpdater updater = new DatabaseUpdate.Updater(objectSpace, versionFromDB);
return new ModuleUpdater[] { updater };
}
public override void Setup(XafApplication application) {
base.Setup(application);
// Manage various aspects of the application UI and behavior at the module level.
application.SetupComplete += Application_SetupComplete;
}
private void Application_SetupComplete(object sender, EventArgs e) {
Application.ObjectSpaceCreated += Application_ObjectSpaceCreated;
NonPersistentObjectSpace.UseKeyComparisonToDetermineIdentity = true;
}
private void Application_ObjectSpaceCreated(object sender, ObjectSpaceCreatedEventArgs e) {
var npos = e.ObjectSpace as NonPersistentObjectSpace;
if(npos != null) {
IObjectSpace persistentObjectSpace = Application.CreateObjectSpace(typeof(BaseObject));
persistentObjectSpace.ObjectChanged += (s2, e2) => {
npos.SetModified(null);
};
npos.AdditionalObjectSpaces.Add(persistentObjectSpace);
npos.AutoDisposeAdditionalObjectSpaces = true;
npos.AutoRefreshAdditionalObjectSpaces = true;
npos.AutoCommitAdditionalObjectSpaces = true;
new ProductViewAdapter(npos);
}
}
public override void CustomizeTypesInfo(ITypesInfo typesInfo) {
base.CustomizeTypesInfo(typesInfo);
CalculatedPersistentAliasHelper.CustomizeTypesInfo(typesInfo);
}
}
}