forked from DevExpress-Examples/XAF_Security_E4908
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
44 lines (41 loc) · 2.04 KB
/
Program.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
using System.Configuration;
using Microsoft.EntityFrameworkCore;
using DevExpress.EntityFrameworkCore.Security;
using DevExpress.ExpressApp.EFCore;
using DevExpress.ExpressApp.Security;
using DevExpress.Persistent.BaseImpl.EF.PermissionPolicy;
using BusinessObjectsLibrary.BusinessObjects;
using DatabaseUpdater;
using DevExpress.ExpressApp.DC;
namespace WindowsFormsApplication {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
TypesInfo typesInfo = new TypesInfo();
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
CreateDemoData(connectionString, typesInfo);
AuthenticationStandard authentication = new AuthenticationStandard();
SecurityStrategyComplex security = new SecurityStrategyComplex(
typeof(PermissionPolicyUser), typeof(PermissionPolicyRole),
authentication,
typesInfo
);
var objectSpaceProvider = new SecuredEFCoreObjectSpaceProvider<ApplicationDbContext>(security,
typesInfo, connectionString, (builder, connectionString) => builder.UseSqlServer(connectionString).UseChangeTrackingProxies());
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MainForm mainForm = new MainForm(security, objectSpaceProvider);
Application.Run(mainForm);
}
private static void CreateDemoData(string connectionString, TypesInfo typesInfo) {
using (var objectSpaceProvider = new EFCoreObjectSpaceProvider<ApplicationDbContext>(typesInfo, connectionString,
(builder, connectionString) => builder.UseSqlServer(connectionString).UseChangeTrackingProxies()))
using (var objectSpace = objectSpaceProvider.CreateUpdatingObjectSpace(true)) {
new Updater(objectSpace).UpdateDatabase();
}
}
}
}