using System; using System.Collections.Generic; using System.Text; using gr2lib.core.typedefs; 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; } } public class versiontype : Iversiontype { 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; } public override string ToString() { return this.Version; } #region IVersionType Members /// /// Returns a string representation of the Granny2 API Version in format (Major.Minor.Customization.Build) /// public string Version { get { return string.Format("{0}.{1}.{2}.{3}", Major, Minor, Customization, Build); } } private granny_int32x _Major; /// /// Returns the Major of the Granny2 API Version (X.0.0.0) /// public granny_int32x Major { get { return _Major; } } private granny_int32x _Minor; /// /// Returns the Minor of the Granny2 API Version (0.X.0.0) /// public granny_int32x Minor { get { return _Minor; } } private granny_int32x _Customization; /// /// Returns the Customization of the Granny2 API Version - Customization (0.0.X.0) /// public granny_int32x Customization { get { return _Customization; } } private granny_int32x _Build; /// /// Returns the Build of the Granny2 API Version (0.0.0.X) /// public granny_int32x Build { get { return _Build; } } #endregion } #endregion #region public class Granny2APIVersion public interface Igranny2apiversion { bool apiversionsmatch { get; } versiontype apiversion { get; } versiontype expectedapiversion { get; } } /// /// Handle's the checking of the Loaded Granny2 API Version /// public class granny2apiversion : Igranny2apiversion { public granny2apiversion() { this._APIVersion = new versiontype(); this._APIVersionsMatch = this.GrannyVersionsMatch(); this.GetGrannyVersion(); } #region APIVersion Support private class apiversiontype { public static string GrannyProductVersion = "2.7.0.30"; public static granny_int32x GrannyProductMajorVersion = 2; public static granny_int32x GrannyProductMinorVersion = 7; public static granny_int32x GrannyProductCustomization = 0; public static granny_int32x GrannyProductBuildNumber = 30; public static string GrannyProductReleaseName = "release"; }; private bool GrannyVersionsMatch() { return gr2lib.core.coreapi.GrannyVersionsMatch( apiversiontype.GrannyProductMajorVersion, apiversiontype.GrannyProductMinorVersion, apiversiontype.GrannyProductCustomization, apiversiontype.GrannyProductBuildNumber); } private void GetGrannyVersion() { granny_int32x Major = 0; granny_int32x Minor = 0; granny_int32x Customization = 0; granny_int32x Build = 0; gr2lib.core.coreapi.GrannyGetVersion( out Major, out Minor, out Customization, out Build); this._APIVersion = new versiontype(Major, Minor, Customization, Build); } private string GrannyGetVersionString() { return gr2lib.core.coreapi.GrannyGetVersionString(); } #endregion #region IGranny2APIVersion Members private bool _APIVersionsMatch = false; /// /// Indicates that the Loaded Granny2 API Version matches the version that the core library was built against /// public bool apiversionsmatch { get { return _APIVersionsMatch; } } private versiontype _APIVersion; /// /// Gets the Loaded Granny2 API Version /// public versiontype apiversion { get { return _APIVersion; } } /// /// Gets the Expected Granny2 API Version /// public versiontype expectedapiversion { get { return new versiontype(apiversiontype.GrannyProductMajorVersion, apiversiontype.GrannyProductMinorVersion, apiversiontype.GrannyProductCustomization, apiversiontype.GrannyProductBuildNumber); } } #endregion } #endregion }