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 }