mirror of
https://github.com/Biarity/Sieve.git
synced 2024-11-21 21:12:50 +01:00
Implement IEquatable for sort and filter terms, closes #38
This commit is contained in:
parent
3eaff4add4
commit
2d5fc0d232
@ -4,7 +4,7 @@ using System.Text.RegularExpressions;
|
|||||||
|
|
||||||
namespace Sieve.Models
|
namespace Sieve.Models
|
||||||
{
|
{
|
||||||
public class FilterTerm : IFilterTerm
|
public class FilterTerm : IFilterTerm, IEquatable<FilterTerm>
|
||||||
{
|
{
|
||||||
public FilterTerm() { }
|
public FilterTerm() { }
|
||||||
|
|
||||||
@ -76,5 +76,13 @@ namespace Sieve.Models
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool OperatorIsCaseInsensitive { get; private set; }
|
public bool OperatorIsCaseInsensitive { get; private set; }
|
||||||
|
|
||||||
|
public bool Equals(FilterTerm other)
|
||||||
|
{
|
||||||
|
return Names.SequenceEqual(other.Names)
|
||||||
|
&& Values.SequenceEqual(other.Values)
|
||||||
|
&& Operator == other.Operator;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
namespace Sieve.Models
|
using System;
|
||||||
|
|
||||||
|
namespace Sieve.Models
|
||||||
{
|
{
|
||||||
public class SortTerm : ISortTerm
|
public class SortTerm : ISortTerm, IEquatable<SortTerm>
|
||||||
{
|
{
|
||||||
public SortTerm() { }
|
public SortTerm() { }
|
||||||
|
|
||||||
@ -17,5 +19,11 @@
|
|||||||
public string Name => (_sort.StartsWith("-")) ? _sort.Substring(1) : _sort;
|
public string Name => (_sort.StartsWith("-")) ? _sort.Substring(1) : _sort;
|
||||||
|
|
||||||
public bool Descending => _sort.StartsWith("-");
|
public bool Descending => _sort.StartsWith("-");
|
||||||
|
|
||||||
|
public bool Equals(SortTerm other)
|
||||||
|
{
|
||||||
|
return Name == other.Name
|
||||||
|
&& Descending == other.Descending;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user