This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinApplication.cs
53 lines (52 loc) · 2.93 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
51
52
53
using System;
using System.ComponentModel;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Win;
using System.Collections.Generic;
using DevExpress.ExpressApp.Updating;
using DevExpress.ExpressApp.EF;
using DelayedImagesEF.Module.BusinessObjects;
using System.Data.Common;
namespace DelayedImagesEF.Win {
// For more typical usage scenarios, be sure to check out http://documentation.devexpress.com/#Xaf/DevExpressExpressAppWinWinApplicationMembersTopicAll
public partial class DelayedImagesEFWindowsFormsApplication : WinApplication {
public DelayedImagesEFWindowsFormsApplication() {
InitializeComponent();
}
protected override void CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) {
if(args.Connection != null) {
args.ObjectSpaceProvider = new EFObjectSpaceProvider(typeof(DelayedImagesEFDbContext), TypesInfo, null, (DbConnection)args.Connection);
}
else {
args.ObjectSpaceProvider = new EFObjectSpaceProvider(typeof(DelayedImagesEFDbContext), TypesInfo, null, args.ConnectionString);
}
}
private void DelayedImagesEFWindowsFormsApplication_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);
}
}
private void DelayedImagesEFWindowsFormsApplication_DatabaseVersionMismatch(object sender, DevExpress.ExpressApp.DatabaseVersionMismatchEventArgs e) {
#if EASYTEST
e.Updater.Update();
e.Handled = true;
#else
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/");
}
#endif
}
}
}