forked from ClearCanvas/ClearCanvas
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ILicenseDetailsProvider.cs
154 lines (134 loc) · 4.06 KB
/
ILicenseDetailsProvider.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#region License
// Copyright (c) 2013, ClearCanvas Inc.
// All rights reserved.
// http://www.clearcanvas.ca
//
// This file is part of the ClearCanvas RIS/PACS open source project.
//
// The ClearCanvas RIS/PACS open source project is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// The ClearCanvas RIS/PACS open source project is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
// Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// the ClearCanvas RIS/PACS open source project. If not, see
// <http://www.gnu.org/licenses/>.
#endregion
using System;
namespace ClearCanvas.Common
{
/// <summary>
/// Represents a license details provider.
/// </summary>
/// <remarks>
/// For internal framework use only.
/// </remarks>
public interface ILicenseDetailsProvider
{
/// <summary>
/// Gets a string indicating license type.
/// </summary>
string LicenseType { get; }
/// <summary>
/// Gets the licensed diagnostic use.
/// </summary>
LicenseDiagnosticUse DiagnosticUse { get; }
/// <summary>
/// Gets the first run date.
/// </summary>
DateTime? FirstRun { get; }
/// <summary>
/// Gets the status of the license if it is a time-limited trial.
/// </summary>
/// <param name="timeRemaining">Time remaining in trial period.</param>
/// <returns>True if license is for a limited-use trial; False otherwise.</returns>
bool GetTrialStatus(out TimeSpan? timeRemaining);
/// <summary>
/// Gets the license expiry date in local time.
/// </summary>
/// <returns>
/// License expiry time or NULL if the license does not expire.
/// </returns>
DateTime? GetExpiryDate();
/// <summary>
/// Gets a value indicating whether or not a specific feature is authorized by the license.
/// </summary>
/// <param name="featureToken"></param>
/// <returns></returns>
bool IsFeatureAuthorized(string featureToken);
}
/// <summary>
/// Specifies the allowed diagnostic use of the product license.
/// </summary>
public enum LicenseDiagnosticUse
{
/// <summary>
/// Indicates product is not licensed for diagnostic use.
/// </summary>
None,
/// <summary>
/// Indicates product is licensed for general diagnostic use, including humans.
/// </summary>
Allowed,
/// <summary>
/// Indicates product is licensed only for veterinary diagnosis.
/// </summary>
VeterinaryOnly
}
/// <summary>
/// An extension point for <see cref="ILicenseDetailsProvider"/>s.
/// </summary>
/// <remarks>
/// For internal framework use only.
/// </remarks>
[ExtensionPoint]
public sealed class LicenseDetailsProviderExtensionPoint : ExtensionPoint<ILicenseDetailsProvider>
{
private LicenseDetailsProviderExtensionPoint() {}
internal static ILicenseDetailsProvider CreateInstance()
{
try
{
// check for a provider extension
return (ILicenseDetailsProvider) new LicenseDetailsProviderExtensionPoint().CreateExtension();
}
catch (NotSupportedException)
{
return new DefaultLicenseDetailsProvider();
}
}
private sealed class DefaultLicenseDetailsProvider : ILicenseDetailsProvider
{
public string LicenseType
{
get { return null; }
}
public LicenseDiagnosticUse DiagnosticUse
{
get { return LicenseDiagnosticUse.None; }
}
public DateTime? FirstRun
{
get { return null; }
}
public bool GetTrialStatus(out TimeSpan? timeRemaining)
{
timeRemaining = null;
return false;
}
public DateTime? GetExpiryDate()
{
return null;
}
public bool IsFeatureAuthorized(string featureToken)
{
return true;
}
}
}
}