forked from syncfusion/wpf-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.xaml.cs
61 lines (57 loc) · 2.06 KB
/
App.xaml.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
61
#region Copyright Syncfusion Inc. 2001-2021.
// Copyright Syncfusion Inc. 2001-2021. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// [email protected]. Any infringement will be prosecuted under
// applicable laws.
#endregion
using syncfusion.demoscommon.wpf;
using System.Reflection;
using System.Windows;
using Syncfusion.Licensing;
using System.IO;
using System.Text;
namespace syncfusion.spellcheckerdemo.wpf
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
SyncfusionLicenseProvider.RegisterLicense(DemoCommon.FindLicenseKey());
}
protected override void OnStartup(StartupEventArgs e)
{
var window = new MainWindow(new SpellCheckerDemoViewModel());
window.Show();
base.OnStartup(e);
}
}
public static class DemoCommon
{
/// <summary>
/// Helper method to find a syncfusion license key from the Common folder
/// </summary>
/// <param name="fileName">File name of the syncfusion license key</param>
/// <returns></returns>
public static string FindLicenseKey()
{
int levelsToCheck = 12;
string filePath = @"..\SyncfusionLicense.txt";
string rootPath = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase.Replace(@"file:///", ""));
for (int n = 0; n < levelsToCheck; n++)
{
string fileDataPath = System.IO.Path.Combine(rootPath, filePath);
if (System.IO.File.Exists(fileDataPath))
return File.ReadAllText(fileDataPath, Encoding.UTF8);
DirectoryInfo rootDirectory = Directory.GetParent(rootPath);
if (rootDirectory == null)
break;
rootPath = rootDirectory.FullName;
}
return string.Empty;
}
}
}