/[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 42 by william, Thu Jul 15 04:37:01 2010 UTC revision 191 by william, Sat Jul 24 06:31:50 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    using System.ComponentModel;
9    
10  namespace gr2lib.core.apiversion  namespace gr2lib.core.apiversion
11  {  {
12      #region public class VersionType      #region public class VersionType
13        /// <summary>
14        /// Iversiontype inteface
15        /// </summary>
16      public interface Iversiontype      public interface Iversiontype
17      {      {
18          granny_int32x major { get; }          /// <summary>
19          granny_int32x minor { get; }          /// get/set the major
20          granny_int32x customization { get; }          /// </summary>
21          granny_int32x build { get; }          int major { get; set; }
22          string version { get; }          /// <summary>
23            /// get/set the minor
24            /// </summary>
25            int minor { get; set; }
26            /// <summary>
27            /// get/set the customization
28            /// </summary>
29            int customization { get; set; }
30            /// <summary>
31            /// get/set the build
32            /// </summary>
33            int build { get; set; }
34            //string version { get; }
35      }      }
36        /// <summary>
37        /// versiontype class
38        /// </summary>
39      public class versiontype : Iversiontype      public class versiontype : Iversiontype
40      {      {
41            /// <summary>
42            /// default versiontype construction: 0.0.0.0
43            /// </summary>
44          public versiontype()          public versiontype()
45          {          {
46              this.major = 0;              this.major = 0;
# Line 25  namespace gr2lib.core.apiversion Line 48  namespace gr2lib.core.apiversion
48              this.customization = 0;              this.customization = 0;
49              this.build = 0;              this.build = 0;
50          }          }
51          public versiontype(granny_int32x major, granny_int32x minor, granny_int32x customization, granny_int32x build)          /// <summary>
52            /// versiontype construction: major.minor.customization.build
53            /// </summary>
54            public versiontype(int major, int minor, int customization, int build)
55          {          {
56              this.major = major;              this.major = major;
57              this.minor = minor;              this.minor = minor;
58              this.customization = customization;              this.customization = customization;
59              this.build = build;              this.build = build;
60          }          }
61            /// <summary>
62            /// versiontype construction: major.minor.customization.build (via string: "0.0.0.0")
63            /// </summary>
64            public versiontype(string version)
65            {
66                string[] _version = version.Split('.');
67                
68                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            }
73            /// <summary>
74            /// Gets this version in format: major.minor.customization.build
75            /// </summary>
76            /// <returns></returns>
77          public override string ToString()          public override string ToString()
78          {          {
79              return this.version;              return this.version;
# Line 42  namespace gr2lib.core.apiversion Line 83  namespace gr2lib.core.apiversion
83          /// <summary>          /// <summary>
84          /// 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)
85          /// </summary>          /// </summary>
86          public string version { get { return string.Format("{0}.{1}.{2}.{3}", major, minor, customization, build); } }          private string version { get { return string.Format("{0}.{1}.{2}.{3}", major, minor, customization, build); } }
87          private granny_int32x _major;          private int _major;
88          /// <summary>          /// <summary>
89          /// Returns the Major of the Granny2 API Version (X.0.0.0)          /// Returns the Major of the Granny2 API Version (X.0.0.0)
90          /// </summary>          /// </summary>
91          public granny_int32x major { get { return _major; } private set { _major = value; } }          [RefreshPropertiesAttribute(RefreshProperties.All)]        
92            public int major { get { return _major; } set { _major = value; } }
93    
94          private granny_int32x _minor;          private int _minor;
95          /// <summary>          /// <summary>
96          /// Returns the Minor of the Granny2 API Version (0.X.0.0)          /// Returns the Minor of the Granny2 API Version (0.X.0.0)
97          /// </summary>          /// </summary>
98          public granny_int32x minor { get { return _minor; } private set { _minor = value; } }          [RefreshPropertiesAttribute(RefreshProperties.All)]        
99            public int minor { get { return _minor; } set { _minor = value; } }
100    
101          private granny_int32x _customization;          private int _customization;
102          /// <summary>          /// <summary>
103          /// 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)
104          /// </summary>          /// </summary>
105          public granny_int32x customization { get { return _customization; } private set { _customization = value; } }          [RefreshPropertiesAttribute(RefreshProperties.All)]          
106            public int customization { get { return _customization; } set { _customization = value; } }
107    
108          private granny_int32x _build;          private int _build;
109          /// <summary>          /// <summary>
110          /// Returns the Build of the Granny2 API Version (0.0.0.X)          /// Returns the Build of the Granny2 API Version (0.0.0.X)
111          /// </summary>          /// </summary>
112          public granny_int32x build { get { return _build; } private set { _build = value; } }          [RefreshPropertiesAttribute(RefreshProperties.All)]  
113            public int build { get { return _build; } set { _build = value; } }
114          #endregion          #endregion
115      }      }
116      #endregion      #endregion
117    
118      #region public class Granny2APIVersion      #region public class Granny2APIVersion
     public interface Igranny2apiversion  
     {  
         bool apiversionsmatch { get; }  
         versiontype apiversion { get; }  
         versiontype expectedapiversion { get; }  
     }  
119      /// <summary>      /// <summary>
120      /// Handle's the checking of the Loaded Granny2 API Version      /// Handle's the checking of the Loaded Granny2 API Version
121      /// </summary>      /// </summary>
122      public class granny2apiversion : Igranny2apiversion      public class granny2apiversion : igranny2apiversion
123      {      {
124            /// <summary>
125            /// Default granny2apiversion Constructor: Expect Granny2 API -> 2.7.0.30
126            /// </summary>
127          public granny2apiversion()          public granny2apiversion()
128          {          {
129              this._APIVersion = new versiontype();              this._expectedapiversion = new versiontype(
130              this._APIVersionsMatch = this.GrannyVersionsMatch();                                               apiversiontype.GrannyProductMajorVersion,
131                                                 apiversiontype.GrannyProductMinorVersion,
132                                                 apiversiontype.GrannyProductCustomization,
133                                                 apiversiontype.GrannyProductBuildNumber);
134    
135                granny2apiloader _loader = new granny2apiloader(true);
136                this._apiversion = new versiontype();
137                this._apiversionsmatch = this.GrannyVersionsMatch();
138                this.GetGrannyVersion();
139    
140            }
141            /// <summary>
142            /// 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            /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build
163            /// </summary>
164            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                granny2apiloader _loader = new granny2apiloader(true);
173                this._apiversion = new versiontype();
174                this._apiversionsmatch = this.GrannyVersionsMatch();
175              this.GetGrannyVersion();              this.GetGrannyVersion();
176          }            }
177            /// <summary>
178            /// 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            /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build (via string: "0.0.0.0")
198            /// </summary>
199            public granny2apiversion(string ExceptedVersion)
200            {
201                this._expectedapiversion = new versiontype(ExceptedVersion);
202    
203                granny2apiloader _loader = new granny2apiloader(true);
204                this._apiversion = new versiontype();
205                this._apiversionsmatch = this.GrannyVersionsMatch();
206                this.GetGrannyVersion();
207            }
208            /// <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    
217                    granny2apiloader _loader = new granny2apiloader(checkforgrannyapi);
218                    this._apiversion = new versiontype();
219                    this._apiversionsmatch = this.GrannyVersionsMatch();
220                    this.GetGrannyVersion();
221                }
222            }
223    
224          #region APIVersion Support          #region APIVersion Support
225          private class apiversiontype          private class apiversiontype
226          {          {
# Line 101  namespace gr2lib.core.apiversion Line 234  namespace gr2lib.core.apiversion
234    
235          private bool GrannyVersionsMatch()          private bool GrannyVersionsMatch()
236          {          {
237              return gr2lib.core.coreapi.GrannyVersionsMatch(              return gr2lib.core.coreapi.VersionSupport.GrannyVersionsMatch(
238                  apiversiontype.GrannyProductMajorVersion,                  this._expectedapiversion.major,
239                  apiversiontype.GrannyProductMinorVersion,                  this._expectedapiversion.minor,
240                  apiversiontype.GrannyProductCustomization,                  this._expectedapiversion.customization,
241                  apiversiontype.GrannyProductBuildNumber);                  this._expectedapiversion.build);
242          }          }
243          private void GetGrannyVersion()          private void GetGrannyVersion()
244          {          {
245              granny_int32x Major = 0;              granny_int32x major = 0;
246              granny_int32x Minor = 0;              granny_int32x minor = 0;
247              granny_int32x Customization = 0;              granny_int32x customization = 0;
248              granny_int32x Build = 0;              granny_int32x build = 0;
249    
250              gr2lib.core.coreapi.GrannyGetVersion(              gr2lib.core.coreapi.VersionSupport.GrannyGetVersion(
251                  ref Major,                  ref major,
252                  ref Minor,                  ref minor,
253                  ref Customization,                  ref customization,
254                  ref Build);                  ref build);
255    
256              this._APIVersion = new versiontype(Major, Minor, Customization, Build);              this._apiversion = new versiontype(major, minor, customization, build);
257    
258          }          }
259          private string GrannyGetVersionString()          private string GrannyGetVersionString()
260          {          {
261              return gr2lib.core.coreapi.GrannyGetVersionString();              return gr2lib.core.coreapi.VersionSupport.GrannyGetVersionString();
262          }          }
263          #endregion          #endregion
264    
265          #region IGranny2APIVersion Members          #region IGranny2APIVersion Members
266          private bool _APIVersionsMatch = false;          private bool _apiversionsmatch = false;
267          /// <summary>          /// <summary>
268          /// 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
269          /// </summary>          /// </summary>
270          public bool apiversionsmatch { get { return _APIVersionsMatch; } }          public bool apiversionsmatch { get { return _apiversionsmatch; } }
271          private versiontype _APIVersion;          private versiontype _apiversion;
272          /// <summary>          /// <summary>
273          /// Gets the Loaded Granny2 API Version          /// Gets the Loaded Granny2 API Version
274          /// </summary>          /// </summary>
275          public versiontype apiversion { get { return _APIVersion; } }          public versiontype apiversion { get { return _apiversion; } }
276            private versiontype _expectedapiversion;
277          /// <summary>          /// <summary>
278          /// Gets the Expected Granny2 API Version          /// Gets the Expected Granny2 API Version
279          /// </summary>          /// </summary>
280          public versiontype expectedapiversion { get { return new versiontype(apiversiontype.GrannyProductMajorVersion, apiversiontype.GrannyProductMinorVersion, apiversiontype.GrannyProductCustomization, apiversiontype.GrannyProductBuildNumber); } }          public versiontype expectedapiversion { get { return _expectedapiversion; } }
281          #endregion          #endregion
282      }      }
283      #endregion      #endregion

Legend:
Removed from v.42  
changed lines
  Added in v.191

  ViewVC Help
Powered by ViewVC 1.1.22