This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
/
WinApplication.cs
50 lines (48 loc) · 2.88 KB
/
WinApplication.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using DevExpress.ExpressApp.Win;
using DevExpress.ExpressApp.Updating;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Xpo;
using System.Configuration;
using DevExpress.ExpressApp.EF;
using MultipleORMsExample.Module.BusinessObjects;
using DevExpress.ExpressApp.DC;
namespace MultipleORMsExample.Win {
public partial class MultipleORMsExampleWindowsFormsApplication : WinApplication {
public MultipleORMsExampleWindowsFormsApplication() {
InitializeComponent();
DelayedViewItemsInitialization = true;
}
protected override void CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) {
args.ObjectSpaceProviders.Add(
new XPObjectSpaceProvider(ConfigurationManager.ConnectionStrings["ConnectionStringXpo"].ConnectionString, null));
args.ObjectSpaceProviders.Add(
new EFObjectSpaceProvider(typeof(MyDbContext),
ConfigurationManager.ConnectionStrings["ConnectionStringEF"].ConnectionString));
}
private void MultipleORMsExampleWindowsFormsApplication_DatabaseVersionMismatch(object sender, DevExpress.ExpressApp.DatabaseVersionMismatchEventArgs e) {
if (System.Diagnostics.Debugger.IsAttached) {
e.Updater.Update();
e.Handled = true;
}
else {
throw new InvalidOperationException(
"The application cannot connect to the specified database, because the latter doesn't exist or its version is older than that of the application.\r\n" +
"This error occurred because the automatic database update was disabled when the application was started without debugging.\r\n" +
"To avoid this error, you should either start the application under Visual Studio in debug mode, or modify the " +
"source code of the 'DatabaseVersionMismatch' event handler to enable automatic database update, " +
"or manually create a database using the 'DBUpdater' tool.\r\n" +
"Anyway, refer to the 'Update Application and Database Versions' help topic at http://www.devexpress.com/Help/?document=ExpressApp/CustomDocument2795.htm " +
"for more detailed information. If this doesn't help, please contact our Support Team at http://www.devexpress.com/Support/Center/");
}
}
private void MultipleORMsExampleWindowsFormsApplication_CustomizeLanguagesList(object sender, CustomizeLanguagesListEventArgs e) {
string userLanguageName = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
if (userLanguageName != "en-US" && e.Languages.IndexOf(userLanguageName) == -1) {
e.Languages.Add(userLanguageName);
}
}
}
}