implement equality for Dimension2D
This commit is contained in:
parent
1c67e6a4e0
commit
05d18bdfda
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace MBS.Framework.Drawing
|
||||
{
|
||||
public class Dimension2D : Dimension
|
||||
public class Dimension2D : Dimension, IEquatable<Dimension2D>
|
||||
{
|
||||
private double mvarWidth = 0.0;
|
||||
public double Width { get { return mvarWidth; } set { mvarWidth = value; } }
|
||||
@ -31,5 +33,36 @@ namespace MBS.Framework.Drawing
|
||||
{
|
||||
return Width.ToString() + "x" + Height.ToString();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Dimension2D)
|
||||
{
|
||||
return ((Dimension2D)obj).Width.Equals(Width) && ((Dimension2D)obj).Height.Equals(Height);
|
||||
}
|
||||
return base.Equals(obj);
|
||||
}
|
||||
public bool Equals(Dimension2D other)
|
||||
{
|
||||
if ((object)other == null) return (object)this == null;
|
||||
return Width.Equals(other.Width) && Height.Equals(other.Height);
|
||||
}
|
||||
|
||||
public static bool operator ==(Dimension2D left, Dimension2D right)
|
||||
{
|
||||
if ((left is null) && (right is null))
|
||||
return true;
|
||||
if ((left is null) || (right is null))
|
||||
return false;
|
||||
return left.Equals(right);
|
||||
}
|
||||
public static bool operator !=(Dimension2D left, Dimension2D right)
|
||||
{
|
||||
if ((left is null) && (right is null))
|
||||
return false;
|
||||
if ((left is null) || (right is null))
|
||||
return true;
|
||||
return !left.Equals(right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user