/[gr2lib]/trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs
ViewVC logotype

Annotation of /trunk/gr2lib/core/coreclasses/apiversion/granny2apiversion.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49 - (hide annotations) (download)
Thu Jul 15 07:39:08 2010 UTC (9 years, 4 months ago) by william
File size: 5655 byte(s)
implement granny2apiload exception

1 william 37 using System;
2     using System.Collections.Generic;
3     using System.Text;
4    
5     using gr2lib.core.typedefs;
6 william 49 using gr2lib.core.exceptions;
7 william 37
8     namespace gr2lib.core.apiversion
9     {
10     #region public class VersionType
11     public interface Iversiontype
12     {
13 william 42 granny_int32x major { get; }
14     granny_int32x minor { get; }
15     granny_int32x customization { get; }
16     granny_int32x build { get; }
17     string version { get; }
18 william 37 }
19    
20     public class versiontype : Iversiontype
21     {
22     public versiontype()
23     {
24 william 42 this.major = 0;
25     this.minor = 0;
26     this.customization = 0;
27     this.build = 0;
28 william 37 }
29 william 42 public versiontype(granny_int32x major, granny_int32x minor, granny_int32x customization, granny_int32x build)
30 william 37 {
31 william 42 this.major = major;
32     this.minor = minor;
33     this.customization = customization;
34     this.build = build;
35 william 37 }
36    
37     public override string ToString()
38     {
39 william 42 return this.version;
40 william 37 }
41    
42     #region IVersionType Members
43     /// <summary>
44 william 42 /// Returns a string representation of the Granny2 API Version in format (major.minor.customization.build)
45 william 37 /// </summary>
46 william 42 public string version { get { return string.Format("{0}.{1}.{2}.{3}", major, minor, customization, build); } }
47     private granny_int32x _major;
48 william 37 /// <summary>
49     /// Returns the Major of the Granny2 API Version (X.0.0.0)
50     /// </summary>
51 william 42 public granny_int32x major { get { return _major; } private set { _major = value; } }
52 william 37
53 william 42 private granny_int32x _minor;
54 william 37 /// <summary>
55     /// Returns the Minor of the Granny2 API Version (0.X.0.0)
56     /// </summary>
57 william 42 public granny_int32x minor { get { return _minor; } private set { _minor = value; } }
58 william 37
59 william 42 private granny_int32x _customization;
60 william 37 /// <summary>
61     /// Returns the Customization of the Granny2 API Version - Customization (0.0.X.0)
62     /// </summary>
63 william 42 public granny_int32x customization { get { return _customization; } private set { _customization = value; } }
64 william 37
65 william 42 private granny_int32x _build;
66 william 37 /// <summary>
67     /// Returns the Build of the Granny2 API Version (0.0.0.X)
68     /// </summary>
69 william 42 public granny_int32x build { get { return _build; } private set { _build = value; } }
70 william 37 #endregion
71     }
72     #endregion
73    
74     #region public class Granny2APIVersion
75 william 45 public interface igranny2apiversion
76 william 37 {
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 william 45 public class granny2apiversion : igranny2apiversion
85 william 37 {
86     public granny2apiversion()
87     {
88 william 49 granny2apiloader _loader = new granny2apiloader();
89 william 45 this._apiversion = new versiontype();
90     this._apiversionsmatch = this.GrannyVersionsMatch();
91 william 37 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 william 45 granny_int32x major = 0;
115     granny_int32x minor = 0;
116     granny_int32x customization = 0;
117     granny_int32x build = 0;
118 william 37
119     gr2lib.core.coreapi.GrannyGetVersion(
120 william 45 ref major,
121     ref minor,
122     ref customization,
123     ref build);
124 william 37
125 william 45 this._apiversion = new versiontype(major, minor, customization, build);
126 william 37
127     }
128     private string GrannyGetVersionString()
129     {
130     return gr2lib.core.coreapi.GrannyGetVersionString();
131     }
132     #endregion
133    
134     #region IGranny2APIVersion Members
135 william 45 private bool _apiversionsmatch = false;
136 william 37 /// <summary>
137     /// Indicates that the Loaded Granny2 API Version matches the version that the core library was built against
138     /// </summary>
139 william 45 public bool apiversionsmatch { get { return _apiversionsmatch; } }
140     private versiontype _apiversion;
141 william 37 /// <summary>
142     /// Gets the Loaded Granny2 API Version
143     /// </summary>
144 william 45 public versiontype apiversion { get { return _apiversion; } }
145 william 37 /// <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     }

  ViewVC Help
Powered by ViewVC 1.1.22