Chronos Plugins 5.11.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
LicenseCheck.cs
Go to the documentation of this file.
1using System;
2using System.IO;
3using System.Reflection;
8
9[assembly: MockLicenseCheck]
10
11namespace MockPlugin.Misc
12{
13
19 {
20 public override string CheckLicense()
21 {
22 if (!LicenseAlreadyOk())
23 {
24 var vm = Helpers.UtilityFactories.CreateViewModel<LicenseCheckViewModel>();
25 vm.AcceptedProductIDs = new []{4711};
26 // Our extremely secure reference date for the license check.
27 vm.ProductReferenceDate = new FileInfo(Assembly.GetExecutingAssembly().Location).CreationTime;
28 vm.ValidityAfterReferenceDate = TimeSpan.FromDays(123);
29
30 vm.Explanation = new NoLicenseNeededExplanation();
31 vm.ActivationUriBuilder = () => new Uri($"https://github.com/AxelSemrau/ChronosMockPlugin?ID={vm.ComputerId}&Serial={vm.SerialNumber}");
32 var view = Helpers.UtilityFactories.CreateView<LicenseCheckDialog>();
33 view.DataContext = vm;
34 view.ShowDialog();
35 if (!vm.IsActivationKeyOk)
36 {
37 Helpers.Debug.TraceWrite("No valid license");
38 }
39 // ReSharper disable once RedundantIfElseBlock
40 else
41 {
42 // save the license information
43 }
44 }
45 // For our demo plugin, the license is always ok. Otherwise, we would tell the reason here and get a log entry stating why the plugin can't be loaded.
46 return null;
47 }
48
53 private bool LicenseAlreadyOk() => false;
54 }
55}
Classes and interfaces that are meant for plugins. The classes and interfaces below this namespace ar...
ViewModels provided by Chronos - currently just for license checking.
Placeholder for the Chronos provided license check dialog window. To use the real dialog,...
Contains things that do not fit into the other categories.
void TraceWrite(string text, params object[] arguments)
Write something to the Chronos trace log.
Static instance for access to utility functions and resources.
Definition Helpers.cs:79
static IUtilityFactories UtilityFactories
Helper class factories, see the members for details.
Definition Helpers.cs:113
static IDebugHelper Debug
Utility functions for debugging.
Definition Helpers.cs:98
Use this attribute if you want to expose the contents of your plugin assembly only after a license ch...
Just a placeholder for an internally generated dialog window that uses a LicenseCheckViewModel.
Mock plugin specific license checker.
bool LicenseAlreadyOk()
Check if we have some persistantly saved license state, and this state is ok.
Interaction logic for NoLicenseNeededExplanation.xaml.