/[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

--- trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs	2010/07/15 04:37:01	42
+++ trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs	2010/07/15 08:23:03	55
@@ -3,6 +3,7 @@
 using System.Text;
 
 using gr2lib.core.typedefs;
+using gr2lib.core.exceptions;
 
 namespace gr2lib.core.apiversion
 {
@@ -32,7 +33,15 @@
             this.customization = customization;
             this.build = build;
         }
-
+        public versiontype(string version)
+        {
+            string[] _version = version.Split('.');
+            
+            this.major = _version[0];
+            this.minor = _version[1];
+            this.customization = _version[2];
+            this.build = _version[3];
+        }
         public override string ToString()
         {
             return this.version;
@@ -71,7 +80,7 @@
     #endregion
 
     #region public class Granny2APIVersion
-    public interface Igranny2apiversion
+    public interface igranny2apiversion
     {
         bool apiversionsmatch { get; }
         versiontype apiversion { get; }
@@ -80,14 +89,45 @@
     /// <summary>
     /// Handle's the checking of the Loaded Granny2 API Version
     /// </summary>
-    public class granny2apiversion : Igranny2apiversion
+    public class granny2apiversion : igranny2apiversion
     {
         public granny2apiversion()
         {
-            this._APIVersion = new versiontype();
-            this._APIVersionsMatch = this.GrannyVersionsMatch();
+            this._expectedapiversion = new versiontype(
+                                             apiversiontype.GrannyProductMajorVersion,
+                                             apiversiontype.GrannyProductMinorVersion,
+                                             apiversiontype.GrannyProductCustomization,
+                                             apiversiontype.GrannyProductBuildNumber);
+
+            granny2apiloader _loader = new granny2apiloader();
+            this._apiversion = new versiontype();
+            this._apiversionsmatch = this.GrannyVersionsMatch();
+            this.GetGrannyVersion();
+ 
+        }
+        public granny2apiversion(granny_int32x ExpectedMajorVersion, granny_int32x ExpectedMinorVersion, granny_int32x ExpectedCustomization, granny_int32x ExpectedBuildNumber)
+        {
+            this._expectedapiversion = new versiontype(
+                                 ExpectedMajorVersion,
+                                 ExpectedMinorVersion,
+                                 ExpectedCustomization,
+                                 ExpectedBuildNumber);
+
+            granny2apiloader _loader = new granny2apiloader();
+            this._apiversion = new versiontype();
+            this._apiversionsmatch = this.GrannyVersionsMatch();
             this.GetGrannyVersion();
-        }   
+        }
+        public granny2apiversion(string ExceptedVersion)
+        {
+            this._expectedapiversion = new versiontype(ExceptedVersion);
+
+            granny2apiloader _loader = new granny2apiloader();
+            this._apiversion = new versiontype();
+            this._apiversionsmatch = this.GrannyVersionsMatch();
+            this.GetGrannyVersion();
+        }
+
         #region APIVersion Support
         private class apiversiontype
         {
@@ -102,25 +142,25 @@
         private bool GrannyVersionsMatch()
         {
             return gr2lib.core.coreapi.GrannyVersionsMatch(
-                apiversiontype.GrannyProductMajorVersion,
-                apiversiontype.GrannyProductMinorVersion,
-                apiversiontype.GrannyProductCustomization,
-                apiversiontype.GrannyProductBuildNumber);
+                this._expectedapiversion.major,
+                this._expectedapiversion.minor,
+                this._expectedapiversion.customization,
+                this._expectedapiversion.build);
         }
         private void GetGrannyVersion()
         {
-            granny_int32x Major = 0;
-            granny_int32x Minor = 0;
-            granny_int32x Customization = 0;
-            granny_int32x Build = 0;
+            granny_int32x major = 0;
+            granny_int32x minor = 0;
+            granny_int32x customization = 0;
+            granny_int32x build = 0;
 
             gr2lib.core.coreapi.GrannyGetVersion(
-                ref Major,
-                ref Minor,
-                ref Customization,
-                ref Build);
+                ref major,
+                ref minor,
+                ref customization,
+                ref build);
 
-            this._APIVersion = new versiontype(Major, Minor, Customization, Build);
+            this._apiversion = new versiontype(major, minor, customization, build);
 
         }
         private string GrannyGetVersionString()
@@ -130,20 +170,21 @@
         #endregion
 
         #region IGranny2APIVersion Members
-        private bool _APIVersionsMatch = false;
+        private bool _apiversionsmatch = false;
         /// <summary>
         /// Indicates that the Loaded Granny2 API Version matches the version that the core library was built against
         /// </summary>
-        public bool apiversionsmatch { get { return _APIVersionsMatch; } }
-        private versiontype _APIVersion;
+        public bool apiversionsmatch { get { return _apiversionsmatch; } }
+        private versiontype _apiversion;
         /// <summary>
         /// Gets the Loaded Granny2 API Version
         /// </summary>
-        public versiontype apiversion { get { return _APIVersion; } }
+        public versiontype apiversion { get { return _apiversion; } }
+        private versiontype _expectedapiversion;
         /// <summary>
         /// Gets the Expected Granny2 API Version
         /// </summary>
-        public versiontype expectedapiversion { get { return new versiontype(apiversiontype.GrannyProductMajorVersion, apiversiontype.GrannyProductMinorVersion, apiversiontype.GrannyProductCustomization, apiversiontype.GrannyProductBuildNumber); } }
+        public versiontype expectedapiversion { get { return _expectedapiversion; } }
         #endregion
     }
     #endregion

 

  ViewVC Help
Powered by ViewVC 1.1.22