/[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 133 - (hide annotations) (download)
Sun Jul 18 06:14:54 2010 UTC (9 years, 4 months ago) by william
File size: 10945 byte(s)
implement parsing exporterinfo in usercontrol

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

  ViewVC Help
Powered by ViewVC 1.1.22