Add equality comparison support for most common Dims (#278)

Specifically factor, fill and absolute now support making comparisons.
This commit is contained in:
Daniel Cazzulino
2019-10-25 10:08:19 -04:00
committed by Miguel de Icaza
parent 62f5a96553
commit 369e305871

View File

@@ -311,6 +311,11 @@ namespace Terminal.Gui {
{
return $"Dim.Factor({factor})";
}
public override int GetHashCode () => factor.GetHashCode();
public override bool Equals (object other) => other is DimFactor f && f.factor == factor;
}
/// <summary>
@@ -339,6 +344,11 @@ namespace Terminal.Gui {
{
return n;
}
public override int GetHashCode () => n.GetHashCode();
public override bool Equals (object other) => other is DimAbsolute abs && abs.n == n;
}
class DimFill : Dim {
@@ -353,7 +363,11 @@ namespace Terminal.Gui {
internal override int Anchor (int width)
{
return width-margin;
}
}
public override int GetHashCode () => margin.GetHashCode();
public override bool Equals (object other) => other is DimFill fill && fill.margin == margin;
}
static DimFill zeroMargin;