Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

//
Expand Down Expand Up @@ -1127,6 +1127,25 @@ public bool Equals(GlyphLookupRecord value)
{
return !value1.Equals(value2);
}
public static bool operator <(GlyphLookupRecord left, GlyphLookupRecord right)
{
return left.CompareTo(right) < 0;
}

public static bool operator >(GlyphLookupRecord left, GlyphLookupRecord right)
{
return left.CompareTo(right) > 0;
}

public static bool operator <=(GlyphLookupRecord left, GlyphLookupRecord right)
{
return left.CompareTo(right) <= 0;
}

public static bool operator >=(GlyphLookupRecord left, GlyphLookupRecord right)
{
return left.CompareTo(right) >= 0;
}
public override bool Equals(object value)
{
return Equals((GlyphLookupRecord)value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,51 @@ public int CompareTo(TextEffectBoundary other)
// Starting edge is always in front.
return IsStart ? -1 : 1;
}

public bool Equals(TextEffectBoundary other)
{
return _position == other._position && _isStart == other._isStart;
}

public override bool Equals(object obj)
{
return obj is TextEffectBoundary other && Equals(other);
}

public override int GetHashCode()
{
return HashCode.Combine(_position, _isStart);
}

public static bool operator ==(TextEffectBoundary left, TextEffectBoundary right)
{
return left.Equals(right);
}

public static bool operator !=(TextEffectBoundary left, TextEffectBoundary right)
{
return !left.Equals(right);
}

public static bool operator <(TextEffectBoundary left, TextEffectBoundary right)
{
return left.CompareTo(right) < 0;
}

public static bool operator >(TextEffectBoundary left, TextEffectBoundary right)
{
return left.CompareTo(right) > 0;
}

public static bool operator <=(TextEffectBoundary left, TextEffectBoundary right)
{
return left.CompareTo(right) <= 0;
}

public static bool operator >=(TextEffectBoundary left, TextEffectBoundary right)
{
return left.CompareTo(right) >= 0;
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,54 @@ bool IEquatable<ValidatedPartUri>.Equals(ValidatedPartUri otherPartUri)
{
return Compare(otherPartUri) == 0;
}

#endregion IEqualityComparer Methods
public override bool Equals(object obj)
{
return obj is ValidatedPartUri other && Compare(other) == 0;
}

public override int GetHashCode()
{
return NormalizedPartUriString.GetHashCode();
}

public static bool operator ==(ValidatedPartUri left, ValidatedPartUri right)
{
if (left is null)
return right is null;
return left.Equals(right);
}

public static bool operator !=(ValidatedPartUri left, ValidatedPartUri right) => !(left == right);

public static bool operator <(ValidatedPartUri left, ValidatedPartUri right)
{
if (left is null)
return right is not null;
return left.Compare(right) < 0;
}

public static bool operator >(ValidatedPartUri left, ValidatedPartUri right)
{
if (left is null)
return false;
return left.Compare(right) > 0;
}

public static bool operator <=(ValidatedPartUri left, ValidatedPartUri right)
{
if (left is null)
return true;
return left.Compare(right) <= 0;
}

public static bool operator >=(ValidatedPartUri left, ValidatedPartUri right)
{
if (left is null)
return right is null;
return left.Compare(right) >= 0;
}
#region Internal Properties

//------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,7 @@ internal long EndOffset
}
}
}

int IComparable<MemoryStreamBlock>.CompareTo(MemoryStreamBlock other)
private int Compare(MemoryStreamBlock other)
{
if (other == null)
return 1;
Expand All @@ -895,7 +894,71 @@ int IComparable<MemoryStreamBlock>.CompareTo(MemoryStreamBlock other)
return -1;
}
}
int IComparable<MemoryStreamBlock>.CompareTo(MemoryStreamBlock other)
{
return Compare(other);
}
public bool Equals(MemoryStreamBlock other)
{
if (other == null)
return false;

if (_offset == other.Offset)
return true;
if (_offset >= other.Offset && _offset < other.EndOffset)
return true;
if (other.Offset >= _offset && other.Offset < EndOffset)
return true;

return false;
}
public override bool Equals(object obj)
{
return obj is MemoryStreamBlock other && Equals(other);
}
public override int GetHashCode()
{
return _offset.GetHashCode();
}
public static bool operator ==(MemoryStreamBlock left, MemoryStreamBlock right)
{
if (left is null)
return right is null;
return left.Equals(right);
}

public static bool operator !=(MemoryStreamBlock left, MemoryStreamBlock right)
{
return !(left == right);
}

public static bool operator <(MemoryStreamBlock left, MemoryStreamBlock right)
{
if (left is null)
return right is not null;
return left.Compare(right) < 0;
}

public static bool operator >(MemoryStreamBlock left, MemoryStreamBlock right)
{
if (left is null)
return false;
return left.Compare(right) > 0;
}

public static bool operator <=(MemoryStreamBlock left, MemoryStreamBlock right)
{
if (left is null)
return true;
return left.Compare(right) <= 0;
}

public static bool operator >=(MemoryStreamBlock left, MemoryStreamBlock right)
{
if (left is null)
return right is null;
return left.Compare(right) >= 0;
}
private MemoryStream _stream;
private long _offset;
}
Expand Down