Add comparison methods to mapping classes.
This involved adding Equals and == methods to LineMapping.cs and MappingLocation.cs.
This commit is contained in:
parent
fa342287ad
commit
cadc2fc67e
|
|
@ -3,7 +3,40 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
|
|||
{
|
||||
public class LineMapping
|
||||
{
|
||||
public LineMapping()
|
||||
: this(documentLocation: null, generatedLocation: null)
|
||||
{
|
||||
}
|
||||
|
||||
public LineMapping(MappingLocation documentLocation, MappingLocation generatedLocation)
|
||||
{
|
||||
DocumentLocation = documentLocation;
|
||||
GeneratedLocation = generatedLocation;
|
||||
}
|
||||
|
||||
public MappingLocation DocumentLocation { get; set; }
|
||||
public MappingLocation GeneratedLocation { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
LineMapping other = obj as LineMapping;
|
||||
return DocumentLocation.Equals(other.DocumentLocation) &&
|
||||
GeneratedLocation.Equals(other.GeneratedLocation);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(LineMapping left, LineMapping right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(LineMapping left, LineMapping right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,30 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
|
|||
public int AbsoluteIndex { get; set; }
|
||||
public int LineIndex { get; set; }
|
||||
public int CharacterIndex { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
MappingLocation other = obj as MappingLocation;
|
||||
|
||||
return AbsoluteIndex == other.AbsoluteIndex &&
|
||||
ContentLength == other.ContentLength &&
|
||||
LineIndex == other.LineIndex &&
|
||||
CharacterIndex == other.CharacterIndex;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public static bool operator ==(MappingLocation left, MappingLocation right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(MappingLocation left, MappingLocation right)
|
||||
{
|
||||
return !left.Equals(right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue