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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.40  
changed lines
  Added in v.109

  ViewVC Help
Powered by ViewVC 1.1.22