Chronos Plugins 5.4.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
15 {
16 public override string CheckLicense()
17 {
18 if (!LicenseAlreadyOk())
19 {
20 var vm = Helpers.UtilityFactories.CreateViewModel<LicenseCheckViewModel>();
21 vm.AcceptedProductIDs = new []{4711};
22 // Our extremely secure reference date for the license check.
23 vm.ProductReferenceDate = new FileInfo(Assembly.GetExecutingAssembly().Location).CreationTime;
24 vm.ValidityAfterReferenceDate = TimeSpan.FromDays(123);
25
26 vm.Explanation = new NoLicenseNeededExplanation();
27 vm.ActivationUriBuilder = () => new Uri($"https://github.com/AxelSemrau/ChronosMockPlugin?ID={vm.ComputerId}&Serial={vm.SerialNumber}");
28 var view = Helpers.UtilityFactories.CreateView<LicenseCheckDialog>();
29 view.DataContext = vm;
30 view.ShowDialog();
31 if (!vm.IsActivationKeyOk)
32 {
33 Helpers.Debug.TraceWrite("No valid license");
34 }
35 // ReSharper disable once RedundantIfElseBlock
36 else
37 {
38 // save the license information
39 }
40 }
41 // 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.
42 return null;
43 }
44
49 private bool LicenseAlreadyOk() => false;
50 }
51}
Classes and interfaces that are meant for plugins. The classes and interfaces below this namespace ar...
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:78
static IUtilityFactories UtilityFactories
Helper class factories, see the members for details.
Definition: Helpers.cs:112
static IDebugHelper Debug
Utility functions for debugging.
Definition: Helpers.cs:97
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.
override string CheckLicense()
Do the license check.
Definition: LicenseCheck.cs:16
bool LicenseAlreadyOk()
Check if we have some persistantly saved license state, and this state is ok.
Interaction logic for NoLicenseNeededExplanation.xaml.