ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/gr2lib/trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs
Revision: 49
Committed: Thu Jul 15 07:39:08 2010 UTC (13 years, 4 months ago) by william
File size: 5655 byte(s)
Log Message:
implement granny2apiload exception

File Contents

# Content
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 using gr2lib.core.typedefs;
6 using gr2lib.core.exceptions;
7
8 namespace gr2lib.core.apiversion
9 {
10 #region public class VersionType
11 public interface Iversiontype
12 {
13 granny_int32x major { get; }
14 granny_int32x minor { get; }
15 granny_int32x customization { get; }
16 granny_int32x build { get; }
17 string version { get; }
18 }
19
20 public class versiontype : Iversiontype
21 {
22 public versiontype()
23 {
24 this.major = 0;
25 this.minor = 0;
26 this.customization = 0;
27 this.build = 0;
28 }
29 public versiontype(granny_int32x major, granny_int32x minor, granny_int32x customization, granny_int32x build)
30 {
31 this.major = major;
32 this.minor = minor;
33 this.customization = customization;
34 this.build = build;
35 }
36
37 public override string ToString()
38 {
39 return this.version;
40 }
41
42 #region IVersionType Members
43 /// <summary>
44 /// Returns a string representation of the Granny2 API Version in format (major.minor.customization.build)
45 /// </summary>
46 public string version { get { return string.Format("{0}.{1}.{2}.{3}", major, minor, customization, build); } }
47 private granny_int32x _major;
48 /// <summary>
49 /// Returns the Major of the Granny2 API Version (X.0.0.0)
50 /// </summary>
51 public granny_int32x major { get { return _major; } private set { _major = value; } }
52
53 private granny_int32x _minor;
54 /// <summary>
55 /// Returns the Minor of the Granny2 API Version (0.X.0.0)
56 /// </summary>
57 public granny_int32x minor { get { return _minor; } private set { _minor = value; } }
58
59 private granny_int32x _customization;
60 /// <summary>
61 /// Returns the Customization of the Granny2 API Version - Customization (0.0.X.0)
62 /// </summary>
63 public granny_int32x customization { get { return _customization; } private set { _customization = value; } }
64
65 private granny_int32x _build;
66 /// <summary>
67 /// Returns the Build of the Granny2 API Version (0.0.0.X)
68 /// </summary>
69 public granny_int32x build { get { return _build; } private set { _build = value; } }
70 #endregion
71 }
72 #endregion
73
74 #region public class Granny2APIVersion
75 public interface igranny2apiversion
76 {
77 bool apiversionsmatch { get; }
78 versiontype apiversion { get; }
79 versiontype expectedapiversion { get; }
80 }
81 /// <summary>
82 /// Handle's the checking of the Loaded Granny2 API Version
83 /// </summary>
84 public class granny2apiversion : igranny2apiversion
85 {
86 public granny2apiversion()
87 {
88 granny2apiloader _loader = new granny2apiloader();
89 this._apiversion = new versiontype();
90 this._apiversionsmatch = this.GrannyVersionsMatch();
91 this.GetGrannyVersion();
92 }
93 #region APIVersion Support
94 private class apiversiontype
95 {
96 public static string GrannyProductVersion = "2.7.0.30";
97 public static granny_int32x GrannyProductMajorVersion = 2;
98 public static granny_int32x GrannyProductMinorVersion = 7;
99 public static granny_int32x GrannyProductCustomization = 0;
100 public static granny_int32x GrannyProductBuildNumber = 30;
101 public static string GrannyProductReleaseName = "release";
102 };
103
104 private bool GrannyVersionsMatch()
105 {
106 return gr2lib.core.coreapi.GrannyVersionsMatch(
107 apiversiontype.GrannyProductMajorVersion,
108 apiversiontype.GrannyProductMinorVersion,
109 apiversiontype.GrannyProductCustomization,
110 apiversiontype.GrannyProductBuildNumber);
111 }
112 private void GetGrannyVersion()
113 {
114 granny_int32x major = 0;
115 granny_int32x minor = 0;
116 granny_int32x customization = 0;
117 granny_int32x build = 0;
118
119 gr2lib.core.coreapi.GrannyGetVersion(
120 ref major,
121 ref minor,
122 ref customization,
123 ref build);
124
125 this._apiversion = new versiontype(major, minor, customization, build);
126
127 }
128 private string GrannyGetVersionString()
129 {
130 return gr2lib.core.coreapi.GrannyGetVersionString();
131 }
132 #endregion
133
134 #region IGranny2APIVersion Members
135 private bool _apiversionsmatch = false;
136 /// <summary>
137 /// Indicates that the Loaded Granny2 API Version matches the version that the core library was built against
138 /// </summary>
139 public bool apiversionsmatch { get { return _apiversionsmatch; } }
140 private versiontype _apiversion;
141 /// <summary>
142 /// Gets the Loaded Granny2 API Version
143 /// </summary>
144 public versiontype apiversion { get { return _apiversion; } }
145 /// <summary>
146 /// Gets the Expected Granny2 API Version
147 /// </summary>
148 public versiontype expectedapiversion { get { return new versiontype(apiversiontype.GrannyProductMajorVersion, apiversiontype.GrannyProductMinorVersion, apiversiontype.GrannyProductCustomization, apiversiontype.GrannyProductBuildNumber); } }
149 #endregion
150 }
151 #endregion
152 }