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 |
public string Version { get { return string.Format("{0}.{1}.{2}.{3}", Major, Minor, Customization, Build); } } |
43 |
private granny_int32x _Major; |
44 |
public granny_int32x Major { get { return _Major; } } |
45 |
|
46 |
private granny_int32x _Minor; |
47 |
public granny_int32x Minor { get { return _Minor; } } |
48 |
|
49 |
private granny_int32x _Customization; |
50 |
public granny_int32x Customization { get { return _Customization; } } |
51 |
|
52 |
private granny_int32x _Build; |
53 |
public granny_int32x Build { get { return _Build; } } |
54 |
#endregion |
55 |
} |
56 |
#endregion |
57 |
|
58 |
#region public class Granny2APIVersion |
59 |
public interface IGranny2APIVersion |
60 |
{ |
61 |
bool APIVersionsMatch { get; } |
62 |
VersionType APIVersion { get; } |
63 |
VersionType ExpectedAPIVersion { get; } |
64 |
} |
65 |
public class Granny2APIVersion : IGranny2APIVersion |
66 |
{ |
67 |
public Granny2APIVersion() |
68 |
{ |
69 |
this._APIVersion = new VersionType(); |
70 |
this._APIVersionsMatch = this.GrannyVersionsMatch(); |
71 |
this.GetGrannyVersion(); |
72 |
} |
73 |
#region APIVersion Support |
74 |
private class APIVersionType |
75 |
{ |
76 |
public static string GrannyProductVersion = "2.7.0.30"; |
77 |
public static granny_int32x GrannyProductMajorVersion = 2; |
78 |
public static granny_int32x GrannyProductMinorVersion = 7; |
79 |
public static granny_int32x GrannyProductCustomization = 0; |
80 |
public static granny_int32x GrannyProductBuildNumber = 30; |
81 |
public static string GrannyProductReleaseName = "release"; |
82 |
}; |
83 |
|
84 |
public bool GrannyVersionsMatch() |
85 |
{ |
86 |
return gr2lib.core.coreapi.GrannyVersionsMatch( |
87 |
APIVersionType.GrannyProductMajorVersion, |
88 |
APIVersionType.GrannyProductMinorVersion, |
89 |
APIVersionType.GrannyProductCustomization, |
90 |
APIVersionType.GrannyProductBuildNumber); |
91 |
} |
92 |
public void GetGrannyVersion() |
93 |
{ |
94 |
granny_int32x Major = 0; |
95 |
granny_int32x Minor = 0; |
96 |
granny_int32x Customization = 0; |
97 |
granny_int32x Build = 0; |
98 |
|
99 |
gr2lib.core.coreapi.GrannyGetVersion( |
100 |
out Major, |
101 |
out Minor, |
102 |
out Customization, |
103 |
out Build); |
104 |
|
105 |
this._APIVersion = new VersionType(Major, Minor, Customization, Build); |
106 |
|
107 |
} |
108 |
public string GrannyGetVersionString() |
109 |
{ |
110 |
return gr2lib.core.coreapi.GrannyGetVersionString(); |
111 |
} |
112 |
#endregion |
113 |
|
114 |
#region IGranny2APIVersion Members |
115 |
private bool _APIVersionsMatch = false; |
116 |
public bool APIVersionsMatch { get { return _APIVersionsMatch; } } |
117 |
private VersionType _APIVersion; |
118 |
public VersionType APIVersion { get { return _APIVersion; } } |
119 |
public VersionType ExpectedAPIVersion { get { return new VersionType(APIVersionType.GrannyProductMajorVersion, APIVersionType.GrannyProductMinorVersion, APIVersionType.GrannyProductCustomization, APIVersionType.GrannyProductBuildNumber); } } |
120 |
#endregion |
121 |
} |
122 |
#endregion |
123 |
} |