2005-02-12 Ben Maurer <bmaurer@ximian.com>
+ * Version.cs (CompareTo, Equals): Make sure the versions for
+ generics handle `null'. The non-generics versions now just call
+ the regular versions, to reduce code duplication.
+
* Boolean.cs (CompareTo): make this really work for generics
* Type.cs (GetProperty): Passing new Type [0] is different than
public int CompareTo (object version)
{
- Version v;
-
if (version == null)
return 1;
if (! (version is Version))
throw new ArgumentException (Locale.GetText ("Argument to Version.CompareTo must be a Version."));
- v = version as Version;
-
- if (this._Major > v._Major)
- return 1;
- else if (this._Major < v._Major)
- return -1;
-
- if (this._Minor > v._Minor)
- return 1;
- else if (this._Minor < v._Minor)
- return -1;
-
- if (this._Build > v._Build)
- return 1;
- else if (this._Build < v._Build)
- return -1;
-
- if (this._Revision > v._Revision)
- return 1;
- else if (this._Revision < v._Revision)
- return -1;
-
- return 0;
+ return this.CompareTo ((Version) version);
}
public override bool Equals (object obj)
{
- Version x;
-
- if (obj == null || !(obj is Version))
- return false;
-
- x = (Version) obj;
-
- if ((x._Major == _Major) &&
- (x._Minor == _Minor) &&
- (x._Build == _Build) &&
- (x._Revision == _Revision))
- return true;
- return false;
+ return this.Equals (obj as Version);
}
#if NET_2_0
- public int CompareTo (Version v)
+ public
+#endif
+ int CompareTo (Version v)
{
+ if (v == null)
+ return 1;
+
if (this._Major > v._Major)
return 1;
else if (this._Major < v._Major)
return 0;
}
- public bool Equals (Version x)
+#if NET_2_0
+ public
+#endif
+ bool Equals (Version x)
{
- if ((x._Major == _Major) &&
+ return ((x != null) &&
+ (x._Major == _Major) &&
(x._Minor == _Minor) &&
(x._Build == _Build) &&
- (x._Revision == _Revision))
- return true;
- return false;
+ (x._Revision == _Revision));
}
-#endif
public override int GetHashCode ()
{