/[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 55 - (hide annotations) (download)
Thu Jul 15 08:23:03 2010 UTC (9 years, 4 months ago) by william
File size: 7296 byte(s)
Add support for:
** Setting Expected API Versions

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 37
8     namespace gr2lib.core.apiversion
9     {
10     #region public class VersionType
11     public interface Iversiontype
12     {
13 william 42 granny_int32x major { get; }
14     granny_int32x minor { get; }
15     granny_int32x customization { get; }
16     granny_int32x build { get; }
17     string version { get; }
18 william 37 }
19    
20     public class versiontype : Iversiontype
21     {
22     public versiontype()
23     {
24 william 42 this.major = 0;
25     this.minor = 0;
26     this.customization = 0;
27     this.build = 0;
28 william 37 }
29 william 42 public versiontype(granny_int32x major, granny_int32x minor, granny_int32x customization, granny_int32x build)
30 william 37 {
31 william 42 this.major = major;
32     this.minor = minor;
33     this.customization = customization;
34     this.build = build;
35 william 37 }
36 william 55 public versiontype(string version)
37     {
38     string[] _version = version.Split('.');
39    
40     this.major = _version[0];
41     this.minor = _version[1];
42     this.customization = _version[2];
43     this.build = _version[3];
44     }
45 william 37 public override string ToString()
46     {
47 william 42 return this.version;
48 william 37 }
49    
50     #region IVersionType Members
51     /// <summary>
52 william 42 /// Returns a string representation of the Granny2 API Version in format (major.minor.customization.build)
53 william 37 /// </summary>
54 william 42 public string version { get { return string.Format("{0}.{1}.{2}.{3}", major, minor, customization, build); } }
55     private granny_int32x _major;
56 william 37 /// <summary>
57     /// Returns the Major of the Granny2 API Version (X.0.0.0)
58     /// </summary>
59 william 42 public granny_int32x major { get { return _major; } private set { _major = value; } }
60 william 37
61 william 42 private granny_int32x _minor;
62 william 37 /// <summary>
63     /// Returns the Minor of the Granny2 API Version (0.X.0.0)
64     /// </summary>
65 william 42 public granny_int32x minor { get { return _minor; } private set { _minor = value; } }
66 william 37
67 william 42 private granny_int32x _customization;
68 william 37 /// <summary>
69     /// Returns the Customization of the Granny2 API Version - Customization (0.0.X.0)
70     /// </summary>
71 william 42 public granny_int32x customization { get { return _customization; } private set { _customization = value; } }
72 william 37
73 william 42 private granny_int32x _build;
74 william 37 /// <summary>
75     /// Returns the Build of the Granny2 API Version (0.0.0.X)
76     /// </summary>
77 william 42 public granny_int32x build { get { return _build; } private set { _build = value; } }
78 william 37 #endregion
79     }
80     #endregion
81    
82     #region public class Granny2APIVersion
83 william 45 public interface igranny2apiversion
84 william 37 {
85     bool apiversionsmatch { get; }
86     versiontype apiversion { get; }
87     versiontype expectedapiversion { get; }
88     }
89     /// <summary>
90     /// Handle's the checking of the Loaded Granny2 API Version
91     /// </summary>
92 william 45 public class granny2apiversion : igranny2apiversion
93 william 37 {
94     public granny2apiversion()
95     {
96 william 55 this._expectedapiversion = new versiontype(
97     apiversiontype.GrannyProductMajorVersion,
98     apiversiontype.GrannyProductMinorVersion,
99     apiversiontype.GrannyProductCustomization,
100     apiversiontype.GrannyProductBuildNumber);
101    
102 william 49 granny2apiloader _loader = new granny2apiloader();
103 william 45 this._apiversion = new versiontype();
104     this._apiversionsmatch = this.GrannyVersionsMatch();
105 william 37 this.GetGrannyVersion();
106 william 55
107     }
108     public granny2apiversion(granny_int32x ExpectedMajorVersion, granny_int32x ExpectedMinorVersion, granny_int32x ExpectedCustomization, granny_int32x ExpectedBuildNumber)
109     {
110     this._expectedapiversion = new versiontype(
111     ExpectedMajorVersion,
112     ExpectedMinorVersion,
113     ExpectedCustomization,
114     ExpectedBuildNumber);
115    
116     granny2apiloader _loader = new granny2apiloader();
117     this._apiversion = new versiontype();
118     this._apiversionsmatch = this.GrannyVersionsMatch();
119     this.GetGrannyVersion();
120     }
121     public granny2apiversion(string ExceptedVersion)
122     {
123     this._expectedapiversion = new versiontype(ExceptedVersion);
124    
125     granny2apiloader _loader = new granny2apiloader();
126     this._apiversion = new versiontype();
127     this._apiversionsmatch = this.GrannyVersionsMatch();
128     this.GetGrannyVersion();
129     }
130    
131 william 37 #region APIVersion Support
132     private class apiversiontype
133     {
134     public static string GrannyProductVersion = "2.7.0.30";
135     public static granny_int32x GrannyProductMajorVersion = 2;
136     public static granny_int32x GrannyProductMinorVersion = 7;
137     public static granny_int32x GrannyProductCustomization = 0;
138     public static granny_int32x GrannyProductBuildNumber = 30;
139     public static string GrannyProductReleaseName = "release";
140     };
141    
142     private bool GrannyVersionsMatch()
143     {
144     return gr2lib.core.coreapi.GrannyVersionsMatch(
145 william 55 this._expectedapiversion.major,
146     this._expectedapiversion.minor,
147     this._expectedapiversion.customization,
148     this._expectedapiversion.build);
149 william 37 }
150     private void GetGrannyVersion()
151     {
152 william 45 granny_int32x major = 0;
153     granny_int32x minor = 0;
154     granny_int32x customization = 0;
155     granny_int32x build = 0;
156 william 37
157     gr2lib.core.coreapi.GrannyGetVersion(
158 william 45 ref major,
159     ref minor,
160     ref customization,
161     ref build);
162 william 37
163 william 45 this._apiversion = new versiontype(major, minor, customization, build);
164 william 37
165     }
166     private string GrannyGetVersionString()
167     {
168     return gr2lib.core.coreapi.GrannyGetVersionString();
169     }
170     #endregion
171    
172     #region IGranny2APIVersion Members
173 william 45 private bool _apiversionsmatch = false;
174 william 37 /// <summary>
175     /// Indicates that the Loaded Granny2 API Version matches the version that the core library was built against
176     /// </summary>
177 william 45 public bool apiversionsmatch { get { return _apiversionsmatch; } }
178     private versiontype _apiversion;
179 william 37 /// <summary>
180     /// Gets the Loaded Granny2 API Version
181     /// </summary>
182 william 45 public versiontype apiversion { get { return _apiversion; } }
183 william 55 private versiontype _expectedapiversion;
184 william 37 /// <summary>
185     /// Gets the Expected Granny2 API Version
186     /// </summary>
187 william 55 public versiontype expectedapiversion { get { return _expectedapiversion; } }
188 william 37 #endregion
189     }
190     #endregion
191     }

  ViewVC Help
Powered by ViewVC 1.1.22