1 |
william |
37 |
using System; |
2 |
|
|
using System.Collections.Generic; |
3 |
|
|
using System.Text; |
4 |
|
|
|
5 |
|
|
using gr2lib.core.typedefs; |
6 |
william |
49 |
using gr2lib.core.exceptions; |
7 |
william |
93 |
using gr2lib.core.interfaces; |
8 |
william |
37 |
|
9 |
|
|
namespace gr2lib.core.apiversion |
10 |
|
|
{ |
11 |
|
|
#region public class VersionType |
12 |
|
|
public interface Iversiontype |
13 |
|
|
{ |
14 |
william |
42 |
granny_int32x major { get; } |
15 |
|
|
granny_int32x minor { get; } |
16 |
|
|
granny_int32x customization { get; } |
17 |
|
|
granny_int32x build { get; } |
18 |
|
|
string version { get; } |
19 |
william |
37 |
} |
20 |
|
|
|
21 |
|
|
public class versiontype : Iversiontype |
22 |
|
|
{ |
23 |
william |
60 |
/// <summary> |
24 |
|
|
/// default versiontype construction: 0.0.0.0 |
25 |
|
|
/// </summary> |
26 |
william |
37 |
public versiontype() |
27 |
|
|
{ |
28 |
william |
42 |
this.major = 0; |
29 |
|
|
this.minor = 0; |
30 |
|
|
this.customization = 0; |
31 |
|
|
this.build = 0; |
32 |
william |
37 |
} |
33 |
william |
60 |
/// <summary> |
34 |
|
|
/// versiontype construction: major.minor.customization.build |
35 |
|
|
/// </summary> |
36 |
william |
42 |
public versiontype(granny_int32x major, granny_int32x minor, granny_int32x customization, granny_int32x build) |
37 |
william |
37 |
{ |
38 |
william |
42 |
this.major = major; |
39 |
|
|
this.minor = minor; |
40 |
|
|
this.customization = customization; |
41 |
|
|
this.build = build; |
42 |
william |
37 |
} |
43 |
william |
60 |
/// <summary> |
44 |
|
|
/// versiontype construction: major.minor.customization.build (via string: "0.0.0.0") |
45 |
|
|
/// </summary> |
46 |
william |
55 |
public versiontype(string version) |
47 |
|
|
{ |
48 |
|
|
string[] _version = version.Split('.'); |
49 |
|
|
|
50 |
|
|
this.major = _version[0]; |
51 |
|
|
this.minor = _version[1]; |
52 |
|
|
this.customization = _version[2]; |
53 |
|
|
this.build = _version[3]; |
54 |
|
|
} |
55 |
william |
60 |
/// <summary> |
56 |
|
|
/// Gets this version in format: major.minor.customization.build |
57 |
|
|
/// </summary> |
58 |
|
|
/// <returns></returns> |
59 |
william |
37 |
public override string ToString() |
60 |
|
|
{ |
61 |
william |
42 |
return this.version; |
62 |
william |
37 |
} |
63 |
|
|
|
64 |
|
|
#region IVersionType Members |
65 |
|
|
/// <summary> |
66 |
william |
42 |
/// Returns a string representation of the Granny2 API Version in format (major.minor.customization.build) |
67 |
william |
37 |
/// </summary> |
68 |
william |
42 |
public string version { get { return string.Format("{0}.{1}.{2}.{3}", major, minor, customization, build); } } |
69 |
|
|
private granny_int32x _major; |
70 |
william |
37 |
/// <summary> |
71 |
|
|
/// Returns the Major of the Granny2 API Version (X.0.0.0) |
72 |
|
|
/// </summary> |
73 |
william |
42 |
public granny_int32x major { get { return _major; } private set { _major = value; } } |
74 |
william |
37 |
|
75 |
william |
42 |
private granny_int32x _minor; |
76 |
william |
37 |
/// <summary> |
77 |
|
|
/// Returns the Minor of the Granny2 API Version (0.X.0.0) |
78 |
|
|
/// </summary> |
79 |
william |
42 |
public granny_int32x minor { get { return _minor; } private set { _minor = value; } } |
80 |
william |
37 |
|
81 |
william |
42 |
private granny_int32x _customization; |
82 |
william |
37 |
/// <summary> |
83 |
|
|
/// Returns the Customization of the Granny2 API Version - Customization (0.0.X.0) |
84 |
|
|
/// </summary> |
85 |
william |
42 |
public granny_int32x customization { get { return _customization; } private set { _customization = value; } } |
86 |
william |
37 |
|
87 |
william |
42 |
private granny_int32x _build; |
88 |
william |
37 |
/// <summary> |
89 |
|
|
/// Returns the Build of the Granny2 API Version (0.0.0.X) |
90 |
|
|
/// </summary> |
91 |
william |
42 |
public granny_int32x build { get { return _build; } private set { _build = value; } } |
92 |
william |
37 |
#endregion |
93 |
|
|
} |
94 |
|
|
#endregion |
95 |
|
|
|
96 |
|
|
#region public class Granny2APIVersion |
97 |
|
|
/// <summary> |
98 |
|
|
/// Handle's the checking of the Loaded Granny2 API Version |
99 |
|
|
/// </summary> |
100 |
william |
45 |
public class granny2apiversion : igranny2apiversion |
101 |
william |
37 |
{ |
102 |
william |
60 |
/// <summary> |
103 |
|
|
/// Default granny2apiversion Constructor: Expect Granny2 API -> 2.7.0.30 |
104 |
|
|
/// </summary> |
105 |
william |
37 |
public granny2apiversion() |
106 |
|
|
{ |
107 |
william |
55 |
this._expectedapiversion = new versiontype( |
108 |
|
|
apiversiontype.GrannyProductMajorVersion, |
109 |
|
|
apiversiontype.GrannyProductMinorVersion, |
110 |
|
|
apiversiontype.GrannyProductCustomization, |
111 |
|
|
apiversiontype.GrannyProductBuildNumber); |
112 |
|
|
|
113 |
william |
109 |
granny2apiloader _loader = new granny2apiloader(true); |
114 |
william |
45 |
this._apiversion = new versiontype(); |
115 |
|
|
this._apiversionsmatch = this.GrannyVersionsMatch(); |
116 |
william |
37 |
this.GetGrannyVersion(); |
117 |
william |
55 |
|
118 |
|
|
} |
119 |
william |
60 |
/// <summary> |
120 |
william |
109 |
/// Default granny2apiversion Constructor: Expect Granny2 API -> 2.7.0.30 (allow disable looking for granny api) |
121 |
|
|
/// </summary> |
122 |
|
|
public granny2apiversion(bool checkforgrannyapi) |
123 |
|
|
{ |
124 |
|
|
if (checkforgrannyapi) |
125 |
|
|
{ |
126 |
|
|
this._expectedapiversion = new versiontype( |
127 |
|
|
apiversiontype.GrannyProductMajorVersion, |
128 |
|
|
apiversiontype.GrannyProductMinorVersion, |
129 |
|
|
apiversiontype.GrannyProductCustomization, |
130 |
|
|
apiversiontype.GrannyProductBuildNumber); |
131 |
|
|
|
132 |
|
|
granny2apiloader _loader = new granny2apiloader(checkforgrannyapi); |
133 |
|
|
this._apiversion = new versiontype(); |
134 |
|
|
this._apiversionsmatch = this.GrannyVersionsMatch(); |
135 |
|
|
this.GetGrannyVersion(); |
136 |
|
|
} |
137 |
|
|
|
138 |
|
|
} |
139 |
|
|
/// <summary> |
140 |
william |
60 |
/// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build |
141 |
|
|
/// </summary> |
142 |
william |
55 |
public granny2apiversion(granny_int32x ExpectedMajorVersion, granny_int32x ExpectedMinorVersion, granny_int32x ExpectedCustomization, granny_int32x ExpectedBuildNumber) |
143 |
|
|
{ |
144 |
|
|
this._expectedapiversion = new versiontype( |
145 |
|
|
ExpectedMajorVersion, |
146 |
|
|
ExpectedMinorVersion, |
147 |
|
|
ExpectedCustomization, |
148 |
|
|
ExpectedBuildNumber); |
149 |
|
|
|
150 |
william |
109 |
granny2apiloader _loader = new granny2apiloader(true); |
151 |
william |
55 |
this._apiversion = new versiontype(); |
152 |
|
|
this._apiversionsmatch = this.GrannyVersionsMatch(); |
153 |
|
|
this.GetGrannyVersion(); |
154 |
|
|
} |
155 |
william |
60 |
/// <summary> |
156 |
william |
109 |
/// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build |
157 |
|
|
/// </summary> |
158 |
|
|
public granny2apiversion(bool checkforgrannyapi, granny_int32x ExpectedMajorVersion, granny_int32x ExpectedMinorVersion, granny_int32x ExpectedCustomization, granny_int32x ExpectedBuildNumber) |
159 |
|
|
{ |
160 |
|
|
if (checkforgrannyapi) |
161 |
|
|
{ |
162 |
|
|
this._expectedapiversion = new versiontype( |
163 |
|
|
ExpectedMajorVersion, |
164 |
|
|
ExpectedMinorVersion, |
165 |
|
|
ExpectedCustomization, |
166 |
|
|
ExpectedBuildNumber); |
167 |
|
|
|
168 |
|
|
granny2apiloader _loader = new granny2apiloader(checkforgrannyapi); |
169 |
|
|
this._apiversion = new versiontype(); |
170 |
|
|
this._apiversionsmatch = this.GrannyVersionsMatch(); |
171 |
|
|
this.GetGrannyVersion(); |
172 |
|
|
} |
173 |
|
|
} |
174 |
|
|
/// <summary> |
175 |
william |
60 |
/// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build (via string: "0.0.0.0") |
176 |
|
|
/// </summary> |
177 |
william |
55 |
public granny2apiversion(string ExceptedVersion) |
178 |
|
|
{ |
179 |
|
|
this._expectedapiversion = new versiontype(ExceptedVersion); |
180 |
|
|
|
181 |
william |
109 |
granny2apiloader _loader = new granny2apiloader(true); |
182 |
william |
55 |
this._apiversion = new versiontype(); |
183 |
|
|
this._apiversionsmatch = this.GrannyVersionsMatch(); |
184 |
|
|
this.GetGrannyVersion(); |
185 |
|
|
} |
186 |
william |
109 |
/// <summary> |
187 |
|
|
/// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build (via string: "0.0.0.0") |
188 |
|
|
/// </summary> |
189 |
|
|
public granny2apiversion(bool checkforgrannyapi,string ExceptedVersion) |
190 |
|
|
{ |
191 |
|
|
if (checkforgrannyapi) |
192 |
|
|
{ |
193 |
|
|
this._expectedapiversion = new versiontype(ExceptedVersion); |
194 |
william |
55 |
|
195 |
william |
109 |
granny2apiloader _loader = new granny2apiloader(checkforgrannyapi); |
196 |
|
|
this._apiversion = new versiontype(); |
197 |
|
|
this._apiversionsmatch = this.GrannyVersionsMatch(); |
198 |
|
|
this.GetGrannyVersion(); |
199 |
|
|
} |
200 |
|
|
} |
201 |
|
|
|
202 |
william |
37 |
#region APIVersion Support |
203 |
|
|
private class apiversiontype |
204 |
|
|
{ |
205 |
|
|
public static string GrannyProductVersion = "2.7.0.30"; |
206 |
|
|
public static granny_int32x GrannyProductMajorVersion = 2; |
207 |
|
|
public static granny_int32x GrannyProductMinorVersion = 7; |
208 |
|
|
public static granny_int32x GrannyProductCustomization = 0; |
209 |
|
|
public static granny_int32x GrannyProductBuildNumber = 30; |
210 |
|
|
public static string GrannyProductReleaseName = "release"; |
211 |
|
|
}; |
212 |
|
|
|
213 |
|
|
private bool GrannyVersionsMatch() |
214 |
|
|
{ |
215 |
|
|
return gr2lib.core.coreapi.GrannyVersionsMatch( |
216 |
william |
55 |
this._expectedapiversion.major, |
217 |
|
|
this._expectedapiversion.minor, |
218 |
|
|
this._expectedapiversion.customization, |
219 |
|
|
this._expectedapiversion.build); |
220 |
william |
37 |
} |
221 |
|
|
private void GetGrannyVersion() |
222 |
|
|
{ |
223 |
william |
45 |
granny_int32x major = 0; |
224 |
|
|
granny_int32x minor = 0; |
225 |
|
|
granny_int32x customization = 0; |
226 |
|
|
granny_int32x build = 0; |
227 |
william |
37 |
|
228 |
|
|
gr2lib.core.coreapi.GrannyGetVersion( |
229 |
william |
45 |
ref major, |
230 |
|
|
ref minor, |
231 |
|
|
ref customization, |
232 |
|
|
ref build); |
233 |
william |
37 |
|
234 |
william |
45 |
this._apiversion = new versiontype(major, minor, customization, build); |
235 |
william |
37 |
|
236 |
|
|
} |
237 |
|
|
private string GrannyGetVersionString() |
238 |
|
|
{ |
239 |
|
|
return gr2lib.core.coreapi.GrannyGetVersionString(); |
240 |
|
|
} |
241 |
|
|
#endregion |
242 |
|
|
|
243 |
|
|
#region IGranny2APIVersion Members |
244 |
william |
45 |
private bool _apiversionsmatch = false; |
245 |
william |
37 |
/// <summary> |
246 |
|
|
/// Indicates that the Loaded Granny2 API Version matches the version that the core library was built against |
247 |
|
|
/// </summary> |
248 |
william |
45 |
public bool apiversionsmatch { get { return _apiversionsmatch; } } |
249 |
|
|
private versiontype _apiversion; |
250 |
william |
37 |
/// <summary> |
251 |
|
|
/// Gets the Loaded Granny2 API Version |
252 |
|
|
/// </summary> |
253 |
william |
45 |
public versiontype apiversion { get { return _apiversion; } } |
254 |
william |
55 |
private versiontype _expectedapiversion; |
255 |
william |
37 |
/// <summary> |
256 |
|
|
/// Gets the Expected Granny2 API Version |
257 |
|
|
/// </summary> |
258 |
william |
55 |
public versiontype expectedapiversion { get { return _expectedapiversion; } } |
259 |
william |
37 |
#endregion |
260 |
|
|
} |
261 |
|
|
#endregion |
262 |
|
|
} |