1 |
using System; |
2 |
using System.Collections.Generic; |
3 |
using System.Text; |
4 |
|
5 |
using gr2lib.core.typedefs; |
6 |
|
7 |
namespace gr2lib.core.apiversion |
8 |
{ |
9 |
#region public class VersionType |
10 |
public interface Iversiontype |
11 |
{ |
12 |
granny_int32x major { get; } |
13 |
granny_int32x minor { get; } |
14 |
granny_int32x customization { get; } |
15 |
granny_int32x build { get; } |
16 |
string version { get; } |
17 |
} |
18 |
|
19 |
public class versiontype : Iversiontype |
20 |
{ |
21 |
public versiontype() |
22 |
{ |
23 |
this.major = 0; |
24 |
this.minor = 0; |
25 |
this.customization = 0; |
26 |
this.build = 0; |
27 |
} |
28 |
public versiontype(granny_int32x major, granny_int32x minor, granny_int32x customization, granny_int32x build) |
29 |
{ |
30 |
this.major = major; |
31 |
this.minor = minor; |
32 |
this.customization = customization; |
33 |
this.build = build; |
34 |
} |
35 |
|
36 |
public override string ToString() |
37 |
{ |
38 |
return this.version; |
39 |
} |
40 |
|
41 |
#region IVersionType Members |
42 |
/// <summary> |
43 |
/// Returns a string representation of the Granny2 API Version in format (major.minor.customization.build) |
44 |
/// </summary> |
45 |
public string version { get { return string.Format("{0}.{1}.{2}.{3}", major, minor, customization, build); } } |
46 |
private granny_int32x _major; |
47 |
/// <summary> |
48 |
/// Returns the Major of the Granny2 API Version (X.0.0.0) |
49 |
/// </summary> |
50 |
public granny_int32x major { get { return _major; } private set { _major = value; } } |
51 |
|
52 |
private granny_int32x _minor; |
53 |
/// <summary> |
54 |
/// Returns the Minor of the Granny2 API Version (0.X.0.0) |
55 |
/// </summary> |
56 |
public granny_int32x minor { get { return _minor; } private set { _minor = value; } } |
57 |
|
58 |
private granny_int32x _customization; |
59 |
/// <summary> |
60 |
/// Returns the Customization of the Granny2 API Version - Customization (0.0.X.0) |
61 |
/// </summary> |
62 |
public granny_int32x customization { get { return _customization; } private set { _customization = value; } } |
63 |
|
64 |
private granny_int32x _build; |
65 |
/// <summary> |
66 |
/// Returns the Build of the Granny2 API Version (0.0.0.X) |
67 |
/// </summary> |
68 |
public granny_int32x build { get { return _build; } private set { _build = value; } } |
69 |
#endregion |
70 |
} |
71 |
#endregion |
72 |
|
73 |
#region public class Granny2APIVersion |
74 |
public interface Igranny2apiversion |
75 |
{ |
76 |
bool apiversionsmatch { get; } |
77 |
versiontype apiversion { get; } |
78 |
versiontype expectedapiversion { get; } |
79 |
} |
80 |
/// <summary> |
81 |
/// Handle's the checking of the Loaded Granny2 API Version |
82 |
/// </summary> |
83 |
public class granny2apiversion : Igranny2apiversion |
84 |
{ |
85 |
public granny2apiversion() |
86 |
{ |
87 |
this._APIVersion = new versiontype(); |
88 |
this._APIVersionsMatch = this.GrannyVersionsMatch(); |
89 |
this.GetGrannyVersion(); |
90 |
} |
91 |
#region APIVersion Support |
92 |
private class apiversiontype |
93 |
{ |
94 |
public static string GrannyProductVersion = "2.7.0.30"; |
95 |
public static granny_int32x GrannyProductMajorVersion = 2; |
96 |
public static granny_int32x GrannyProductMinorVersion = 7; |
97 |
public static granny_int32x GrannyProductCustomization = 0; |
98 |
public static granny_int32x GrannyProductBuildNumber = 30; |
99 |
public static string GrannyProductReleaseName = "release"; |
100 |
}; |
101 |
|
102 |
private bool GrannyVersionsMatch() |
103 |
{ |
104 |
return gr2lib.core.coreapi.GrannyVersionsMatch( |
105 |
apiversiontype.GrannyProductMajorVersion, |
106 |
apiversiontype.GrannyProductMinorVersion, |
107 |
apiversiontype.GrannyProductCustomization, |
108 |
apiversiontype.GrannyProductBuildNumber); |
109 |
} |
110 |
private void GetGrannyVersion() |
111 |
{ |
112 |
granny_int32x Major = 0; |
113 |
granny_int32x Minor = 0; |
114 |
granny_int32x Customization = 0; |
115 |
granny_int32x Build = 0; |
116 |
|
117 |
gr2lib.core.coreapi.GrannyGetVersion( |
118 |
ref Major, |
119 |
ref Minor, |
120 |
ref Customization, |
121 |
ref Build); |
122 |
|
123 |
this._APIVersion = new versiontype(Major, Minor, Customization, Build); |
124 |
|
125 |
} |
126 |
private string GrannyGetVersionString() |
127 |
{ |
128 |
return gr2lib.core.coreapi.GrannyGetVersionString(); |
129 |
} |
130 |
#endregion |
131 |
|
132 |
#region IGranny2APIVersion Members |
133 |
private bool _APIVersionsMatch = false; |
134 |
/// <summary> |
135 |
/// Indicates that the Loaded Granny2 API Version matches the version that the core library was built against |
136 |
/// </summary> |
137 |
public bool apiversionsmatch { get { return _APIVersionsMatch; } } |
138 |
private versiontype _APIVersion; |
139 |
/// <summary> |
140 |
/// Gets the Loaded Granny2 API Version |
141 |
/// </summary> |
142 |
public versiontype apiversion { get { return _APIVersion; } } |
143 |
/// <summary> |
144 |
/// Gets the Expected Granny2 API Version |
145 |
/// </summary> |
146 |
public versiontype expectedapiversion { get { return new versiontype(apiversiontype.GrannyProductMajorVersion, apiversiontype.GrannyProductMinorVersion, apiversiontype.GrannyProductCustomization, apiversiontype.GrannyProductBuildNumber); } } |
147 |
#endregion |
148 |
} |
149 |
#endregion |
150 |
} |