diff --git a/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd b/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd
index 8ed4bb7d71..54b73a0b86 100644
--- a/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd
+++ b/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd
@@ -13,6 +13,7 @@
+
diff --git a/BizHawk.Client.Common/tools/Watch/Watch.cs b/BizHawk.Client.Common/tools/Watch/Watch.cs
index c0dd6f762e..0e7a57426c 100644
--- a/BizHawk.Client.Common/tools/Watch/Watch.cs
+++ b/BizHawk.Client.Common/tools/Watch/Watch.cs
@@ -9,6 +9,9 @@ using System.Linq;
namespace BizHawk.Client.Common
{
public abstract partial class Watch
+ : IEquatable,
+ IEquatable,
+ IComparable
{
#region Fields
@@ -33,6 +36,7 @@ namespace BizHawk.Client.Common
/// How you you want to display the value See
/// Specify the endianess. true for big endian
/// A custom note about the
+ /// Occurs when a is incompatible with the
protected Watch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian, string note)
{
if (IsDiplayTypeAvailable(type))
@@ -55,7 +59,7 @@ namespace BizHawk.Client.Common
#endregion
#region Methods
-
+
#region Static
///
@@ -189,6 +193,8 @@ namespace BizHawk.Client.Common
return GenerateWatch(domain, address, size, type, bigEndian, string.Empty, 0, 0, 0);
}
+ #region Operators
+
///
/// Equality operator between two
///
@@ -244,6 +250,56 @@ namespace BizHawk.Client.Common
return !(a == b);
}
+ ///
+ /// Compare two together
+ ///
+ /// First
+ /// Second
+ /// True if first is lesser than b; otherwise, false
+ /// Occurs when you try to compare two throughout different
+ public static bool operator <(Watch a, Watch b)
+ {
+ return a.CompareTo(b) < 0;
+ }
+
+ ///
+ /// Compare two together
+ ///
+ /// First
+ /// Second
+ /// True if first is greater than b; otherwise, false
+ /// Occurs when you try to compare two throughout different
+ public static bool operator >(Watch a, Watch b)
+ {
+ return a.CompareTo(b) > 0;
+ }
+
+ ///
+ /// Compare two together
+ ///
+ /// First
+ /// Second
+ /// True if first is lesser or equals to b; otherwise, false
+ /// Occurs when you try to compare two throughout different
+ public static bool operator <=(Watch a, Watch b)
+ {
+ return a.CompareTo(b) <= 0;
+ }
+
+ ///
+ /// Compare two together
+ ///
+ /// First
+ /// Second
+ /// True if first is greater or equals to b; otherwise, false
+ /// Occurs when you try to compare two throughout different
+ public static bool operator >=(Watch a, Watch b)
+ {
+ return a.CompareTo(b) >= 0;
+ }
+
+ #endregion Operators
+
#endregion Static
#region Abstracts
@@ -359,6 +415,70 @@ namespace BizHawk.Client.Common
_changecount = 0;
}
+ #region IEquatable
+
+ ///
+ /// Determine if this is equals to another
+ ///
+ /// The to compare
+ /// True if both object are equals; otherwise, false
+ public bool Equals(Watch other)
+ {
+ return this._domain == other._domain &&
+ this._address == other._address &&
+ this._size == other._size;
+ }
+
+ #endregion IEquatable
+
+ #region IEquatable
+
+ ///
+ /// Determine if this is equals to an instance of
+ ///
+ /// The to compare
+ /// True if both object are equals; otherwise, false
+ public bool Equals(Cheat other)
+ {
+ return this._domain == other.Domain &&
+ this._address == other.Address &&
+ this._size == other.Size;
+ }
+
+ #endregion IEquatable
+
+ #region IComparable
+
+ ///
+ /// Compare two together and determine wich one comes first.
+ /// First we look the address and then the size
+ ///
+ /// The other to compare to
+ /// 0 if they are equals, 1 if the other is greater, -1 if the other is lesser
+ /// Occurs when you try to compare two throughout different
+ public int CompareTo(Watch other)
+ {
+ if (this._domain != other._domain)
+ {
+ throw new InvalidOperationException("Watch cannot be compared through different domain");
+ }
+
+ if (this.Equals(other))
+ {
+ return 0;
+ }
+ else if (_address.Equals(other._address))
+ {
+ return ((int)_size).CompareTo((int)other._size);
+ }
+ else
+ {
+ return _address.CompareTo(other._address);
+ }
+ }
+
+ #endregion IComparable
+
///
/// Determine if this object is Equals to another
///
@@ -366,19 +486,14 @@ namespace BizHawk.Client.Common
/// True if both object are equals; otherwise, false
public override bool Equals(object obj)
{
- Watch watch = (Watch)obj;
-
if (obj is Watch)
{
- return this.Domain == watch.Domain &&
- this.Address == watch.Address &&
- this.Size == watch.Size &&
- this.Type == watch.Type &&
- this.Notes == watch.Notes;
+ return Equals((Watch)obj);
}
+
else if (obj is Cheat)
{
- return this.Domain == watch.Domain && this.Address == watch.Address;
+ return Equals((Cheat)obj);
}
else
{
@@ -404,7 +519,7 @@ namespace BizHawk.Client.Common
public bool IsDiplayTypeAvailable(DisplayType type)
{
return AvailableTypes().Where(d => d == type).Any();
- }
+ }
///
/// Transform the current instance into a string
@@ -508,6 +623,7 @@ namespace BizHawk.Client.Common
///
/// Gets or set the way current is displayed
///
+ /// Occurs when a is incompatible with the
public DisplayType Type
{
get