/[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 07:39:08	49
+++ trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs	2010/07/17 05:09:00	93
@@ -4,6 +4,7 @@
 
 using gr2lib.core.typedefs;
 using gr2lib.core.exceptions;
+using gr2lib.core.interfaces;
 
 namespace gr2lib.core.apiversion
 {
@@ -19,6 +20,9 @@
 
     public class versiontype : Iversiontype
     {
+        /// <summary>
+        /// default versiontype construction: 0.0.0.0
+        /// </summary>
         public versiontype()
         {
             this.major = 0;
@@ -26,6 +30,9 @@
             this.customization = 0;
             this.build = 0;
         }
+        /// <summary>
+        /// versiontype construction: major.minor.customization.build
+        /// </summary>
         public versiontype(granny_int32x major, granny_int32x minor, granny_int32x customization, granny_int32x build)
         {
             this.major = major;
@@ -33,7 +40,22 @@
             this.customization = customization;
             this.build = build;
         }
-
+        /// <summary>
+        /// versiontype construction: major.minor.customization.build (via string: "0.0.0.0")
+        /// </summary>
+        public versiontype(string version)
+        {
+            string[] _version = version.Split('.');
+            
+            this.major = _version[0];
+            this.minor = _version[1];
+            this.customization = _version[2];
+            this.build = _version[3];
+        }
+        /// <summary>
+        /// Gets this version in format: major.minor.customization.build
+        /// </summary>
+        /// <returns></returns>
         public override string ToString()
         {
             return this.version;
@@ -72,24 +94,57 @@
     #endregion
 
     #region public class Granny2APIVersion
-    public interface igranny2apiversion
-    {
-        bool apiversionsmatch { get; }
-        versiontype apiversion { get; }
-        versiontype expectedapiversion { get; }
-    }
     /// <summary>
     /// Handle's the checking of the Loaded Granny2 API Version
     /// </summary>
     public class granny2apiversion : igranny2apiversion
     {
+        /// <summary>
+        /// Default granny2apiversion Constructor: Expect Granny2 API -> 2.7.0.30
+        /// </summary>
         public granny2apiversion()
         {
+            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();
+ 
+        }
+        /// <summary>
+        /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build
+        /// </summary>
+        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();
+        }
+        /// <summary>
+        /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build (via string: "0.0.0.0")
+        /// </summary>
+        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
         {
@@ -104,10 +159,10 @@
         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()
         {
@@ -142,10 +197,11 @@
         /// Gets the Loaded Granny2 API Version
         /// </summary>
         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