/[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 49 by william, Thu Jul 15 07:39:08 2010 UTC revision 133 by william, Sun Jul 18 06:14:54 2010 UTC
# Line 4  using System.Text; Line 4  using System.Text;
4    
5  using gr2lib.core.typedefs;  using gr2lib.core.typedefs;
6  using gr2lib.core.exceptions;  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      public interface Iversiontype      public interface Iversiontype
14      {      {
15          granny_int32x major { get; }          int major { get; set; }
16          granny_int32x minor { get; }          int minor { get; set; }
17          granny_int32x customization { get; }          int customization { get; set; }
18          granny_int32x build { get; }          int build { get; set; }
19          string version { get; }          //string version { get; }
20      }      }
21    
22      public class versiontype : Iversiontype      public class versiontype : Iversiontype
23      {      {
24            /// <summary>
25            /// default versiontype construction: 0.0.0.0
26            /// </summary>
27          public versiontype()          public versiontype()
28          {          {
29              this.major = 0;              this.major = 0;
# Line 26  namespace gr2lib.core.apiversion Line 31  namespace gr2lib.core.apiversion
31              this.customization = 0;              this.customization = 0;
32              this.build = 0;              this.build = 0;
33          }          }
34          public versiontype(granny_int32x major, granny_int32x minor, granny_int32x customization, granny_int32x build)          /// <summary>
35            /// versiontype construction: major.minor.customization.build
36            /// </summary>
37            public versiontype(int major, int minor, int customization, int build)
38          {          {
39              this.major = major;              this.major = major;
40              this.minor = minor;              this.minor = minor;
41              this.customization = customization;              this.customization = customization;
42              this.build = build;              this.build = build;
43          }          }
44            /// <summary>
45            /// versiontype construction: major.minor.customization.build (via string: "0.0.0.0")
46            /// </summary>
47            public versiontype(string version)
48            {
49                string[] _version = version.Split('.');
50                
51                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            }
56            /// <summary>
57            /// Gets this version in format: major.minor.customization.build
58            /// </summary>
59            /// <returns></returns>
60          public override string ToString()          public override string ToString()
61          {          {
62              return this.version;              return this.version;
# Line 43  namespace gr2lib.core.apiversion Line 66  namespace gr2lib.core.apiversion
66          /// <summary>          /// <summary>
67          /// 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)
68          /// </summary>          /// </summary>
69          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); } }
70          private granny_int32x _major;          private int _major;
71            [RefreshPropertiesAttribute(RefreshProperties.All)]  
72          /// <summary>          /// <summary>
73          /// Returns the Major of the Granny2 API Version (X.0.0.0)          /// Returns the Major of the Granny2 API Version (X.0.0.0)
74          /// </summary>          /// </summary>
75          public granny_int32x major { get { return _major; } private set { _major = value; } }          public int major { get { return _major; } set { _major = value; } }
76    
77          private granny_int32x _minor;          private int _minor;
78            [RefreshPropertiesAttribute(RefreshProperties.All)]  
79          /// <summary>          /// <summary>
80          /// Returns the Minor of the Granny2 API Version (0.X.0.0)          /// Returns the Minor of the Granny2 API Version (0.X.0.0)
81          /// </summary>          /// </summary>
82          public granny_int32x minor { get { return _minor; } private set { _minor = value; } }          public int minor { get { return _minor; } set { _minor = value; } }
83    
84          private granny_int32x _customization;          private int _customization;
85            [RefreshPropertiesAttribute(RefreshProperties.All)]  
86          /// <summary>          /// <summary>
87          /// 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)
88          /// </summary>          /// </summary>
89          public granny_int32x customization { get { return _customization; } private set { _customization = value; } }          public int customization { get { return _customization; } set { _customization = value; } }
90    
91          private granny_int32x _build;          private int _build;
92            [RefreshPropertiesAttribute(RefreshProperties.All)]  
93          /// <summary>          /// <summary>
94          /// Returns the Build of the Granny2 API Version (0.0.0.X)          /// Returns the Build of the Granny2 API Version (0.0.0.X)
95          /// </summary>          /// </summary>
96          public granny_int32x build { get { return _build; } private set { _build = value; } }          public int build { get { return _build; } set { _build = value; } }
97          #endregion          #endregion
98      }      }
99      #endregion      #endregion
100    
101      #region public class Granny2APIVersion      #region public class Granny2APIVersion
     public interface igranny2apiversion  
     {  
         bool apiversionsmatch { get; }  
         versiontype apiversion { get; }  
         versiontype expectedapiversion { get; }  
     }  
102      /// <summary>      /// <summary>
103      /// Handle's the checking of the Loaded Granny2 API Version      /// Handle's the checking of the Loaded Granny2 API Version
104      /// </summary>      /// </summary>
105      public class granny2apiversion : igranny2apiversion      public class granny2apiversion : igranny2apiversion
106      {      {
107            /// <summary>
108            /// Default granny2apiversion Constructor: Expect Granny2 API -> 2.7.0.30
109            /// </summary>
110          public granny2apiversion()          public granny2apiversion()
111          {          {
112              granny2apiloader _loader = new granny2apiloader();              this._expectedapiversion = new versiontype(
113                                                 apiversiontype.GrannyProductMajorVersion,
114                                                 apiversiontype.GrannyProductMinorVersion,
115                                                 apiversiontype.GrannyProductCustomization,
116                                                 apiversiontype.GrannyProductBuildNumber);
117    
118                granny2apiloader _loader = new granny2apiloader(true);
119              this._apiversion = new versiontype();              this._apiversion = new versiontype();
120              this._apiversionsmatch = this.GrannyVersionsMatch();              this._apiversionsmatch = this.GrannyVersionsMatch();
121              this.GetGrannyVersion();              this.GetGrannyVersion();
122          }    
123            }
124            /// <summary>
125            /// 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            /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build
146            /// </summary>
147            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                granny2apiloader _loader = new granny2apiloader(true);
156                this._apiversion = new versiontype();
157                this._apiversionsmatch = this.GrannyVersionsMatch();
158                this.GetGrannyVersion();
159            }
160            /// <summary>
161            /// 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            /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build (via string: "0.0.0.0")
181            /// </summary>
182            public granny2apiversion(string ExceptedVersion)
183            {
184                this._expectedapiversion = new versiontype(ExceptedVersion);
185    
186                granny2apiloader _loader = new granny2apiloader(true);
187                this._apiversion = new versiontype();
188                this._apiversionsmatch = this.GrannyVersionsMatch();
189                this.GetGrannyVersion();
190            }
191            /// <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    
200                    granny2apiloader _loader = new granny2apiloader(checkforgrannyapi);
201                    this._apiversion = new versiontype();
202                    this._apiversionsmatch = this.GrannyVersionsMatch();
203                    this.GetGrannyVersion();
204                }
205            }
206    
207          #region APIVersion Support          #region APIVersion Support
208          private class apiversiontype          private class apiversiontype
209          {          {
# Line 104  namespace gr2lib.core.apiversion Line 218  namespace gr2lib.core.apiversion
218          private bool GrannyVersionsMatch()          private bool GrannyVersionsMatch()
219          {          {
220              return gr2lib.core.coreapi.GrannyVersionsMatch(              return gr2lib.core.coreapi.GrannyVersionsMatch(
221                  apiversiontype.GrannyProductMajorVersion,                  this._expectedapiversion.major,
222                  apiversiontype.GrannyProductMinorVersion,                  this._expectedapiversion.minor,
223                  apiversiontype.GrannyProductCustomization,                  this._expectedapiversion.customization,
224                  apiversiontype.GrannyProductBuildNumber);                  this._expectedapiversion.build);
225          }          }
226          private void GetGrannyVersion()          private void GetGrannyVersion()
227          {          {
# Line 142  namespace gr2lib.core.apiversion Line 256  namespace gr2lib.core.apiversion
256          /// Gets the Loaded Granny2 API Version          /// Gets the Loaded Granny2 API Version
257          /// </summary>          /// </summary>
258          public versiontype apiversion { get { return _apiversion; } }          public versiontype apiversion { get { return _apiversion; } }
259            private versiontype _expectedapiversion;
260          /// <summary>          /// <summary>
261          /// Gets the Expected Granny2 API Version          /// Gets the Expected Granny2 API Version
262          /// </summary>          /// </summary>
263          public versiontype expectedapiversion { get { return new versiontype(apiversiontype.GrannyProductMajorVersion, apiversiontype.GrannyProductMinorVersion, apiversiontype.GrannyProductCustomization, apiversiontype.GrannyProductBuildNumber); } }          public versiontype expectedapiversion { get { return _expectedapiversion; } }
264          #endregion          #endregion
265      }      }
266      #endregion      #endregion

Legend:
Removed from v.49  
changed lines
  Added in v.133

  ViewVC Help
Powered by ViewVC 1.1.22