/[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/14 19:15:42	40
+++ trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs	2010/07/18 01:58:10	109
@@ -3,91 +3,202 @@
 using System.Text;
 
 using gr2lib.core.typedefs;
+using gr2lib.core.exceptions;
+using gr2lib.core.interfaces;
 
 namespace gr2lib.core.apiversion
 {
     #region public class VersionType
     public interface Iversiontype
     {
-        granny_int32x Major { get; }
-        granny_int32x Minor { get; }
-        granny_int32x Customization { get; }
-        granny_int32x Build { get; }
-        string Version { get; }
+        granny_int32x major { get; }
+        granny_int32x minor { get; }
+        granny_int32x customization { get; }
+        granny_int32x build { get; }
+        string version { get; }
     }
 
     public class versiontype : Iversiontype
     {
+        /// <summary>
+        /// default versiontype construction: 0.0.0.0
+        /// </summary>
         public versiontype()
         {
-            this._Major = 0;
-            this._Minor = 0;
-            this._Customization = 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;
+            this.major = 0;
+            this.minor = 0;
+            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;
+            this.minor = minor;
+            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;
+            return this.version;
         }
 
         #region IVersionType Members
         /// <summary>
-        /// 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)
         /// </summary>
-        public string Version { get { return string.Format("{0}.{1}.{2}.{3}", Major, Minor, Customization, Build); } }
-        private granny_int32x _Major;
+        public string version { get { return string.Format("{0}.{1}.{2}.{3}", major, minor, customization, build); } }
+        private granny_int32x _major;
         /// <summary>
         /// Returns the Major of the Granny2 API Version (X.0.0.0)
         /// </summary>
-        public granny_int32x Major { get { return _Major; } }
+        public granny_int32x major { get { return _major; } private set { _major = value; } }
 
-        private granny_int32x _Minor;
+        private granny_int32x _minor;
         /// <summary>
         /// Returns the Minor of the Granny2 API Version (0.X.0.0)
         /// </summary>
-        public granny_int32x Minor { get { return _Minor; } }
+        public granny_int32x minor { get { return _minor; } private set { _minor = value; } }
 
-        private granny_int32x _Customization;
+        private granny_int32x _customization;
         /// <summary>
         /// Returns the Customization of the Granny2 API Version - Customization (0.0.X.0)
         /// </summary>
-        public granny_int32x Customization { get { return _Customization; } }
+        public granny_int32x customization { get { return _customization; } private set { _customization = value; } }
 
-        private granny_int32x _Build;
+        private granny_int32x _build;
         /// <summary>
         /// Returns the Build of the Granny2 API Version (0.0.0.X)
         /// </summary>
-        public granny_int32x Build { get { return _Build; } }
+        public granny_int32x build { get { return _build; } private set { _build = value; } }
         #endregion
     }
     #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
+    public class granny2apiversion : igranny2apiversion
     {
+        /// <summary>
+        /// Default granny2apiversion Constructor: Expect Granny2 API -> 2.7.0.30
+        /// </summary>
         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(true);
+            this._apiversion = new versiontype();
+            this._apiversionsmatch = this.GrannyVersionsMatch();
             this.GetGrannyVersion();
-        }   
+ 
+        }
+        /// <summary>
+        /// Default granny2apiversion Constructor: Expect Granny2 API -> 2.7.0.30 (allow disable looking for granny api)
+        /// </summary>
+        public granny2apiversion(bool checkforgrannyapi)
+        {
+            if (checkforgrannyapi)
+            {
+                this._expectedapiversion = new versiontype(
+                                                 apiversiontype.GrannyProductMajorVersion,
+                                                 apiversiontype.GrannyProductMinorVersion,
+                                                 apiversiontype.GrannyProductCustomization,
+                                                 apiversiontype.GrannyProductBuildNumber);
+
+                granny2apiloader _loader = new granny2apiloader(checkforgrannyapi);
+                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(true);
+            this._apiversion = new versiontype();
+            this._apiversionsmatch = this.GrannyVersionsMatch();
+            this.GetGrannyVersion();
+        }
+        /// <summary>
+        /// granny2apiversion Constructor: set Granny2 API -> major.minor.customization.build
+        /// </summary>
+        public granny2apiversion(bool checkforgrannyapi, granny_int32x ExpectedMajorVersion, granny_int32x ExpectedMinorVersion, granny_int32x ExpectedCustomization, granny_int32x ExpectedBuildNumber)
+        {
+            if (checkforgrannyapi)
+            {
+                this._expectedapiversion = new versiontype(
+                                     ExpectedMajorVersion,
+                                     ExpectedMinorVersion,
+                                     ExpectedCustomization,
+                                     ExpectedBuildNumber);
+
+                granny2apiloader _loader = new granny2apiloader(checkforgrannyapi);
+                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(true);
+            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(bool checkforgrannyapi,string ExceptedVersion)
+        {
+            if (checkforgrannyapi)
+            {
+                this._expectedapiversion = new versiontype(ExceptedVersion);
+
+                granny2apiloader _loader = new granny2apiloader(checkforgrannyapi);
+                this._apiversion = new versiontype();
+                this._apiversionsmatch = this.GrannyVersionsMatch();
+                this.GetGrannyVersion();
+            }
+        }
+
         #region APIVersion Support
         private class apiversiontype
         {
@@ -102,25 +213,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 +241,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