/[gr2lib]/trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs
ViewVC logotype

Annotation of /trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 187 - (hide annotations) (download)
Sat Jul 24 04:16:43 2010 UTC (9 years, 4 months ago) by william
File size: 11420 byte(s)
continue to add xml documentation

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

  ViewVC Help
Powered by ViewVC 1.1.22