wpf-demos/HubTile/CS/App.xaml.cs

59 строки
1.9 KiB
C#

#region Copyright Syncfusion Inc. 2001-2019.
// Copyright Syncfusion Inc. 2001-2019. 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
// licensing@syncfusion.com. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using Syncfusion.Licensing;
using System.Reflection;
using System.IO;
using System.Text;
namespace SfHubTile
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
SyncfusionLicenseProvider.RegisterLicense(DemoCommon.FindLicenseKey());
}
}
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 = @"Common\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;
}
}
}