diff --git a/Sieve/Models/FilterTerm.cs b/Sieve/Models/FilterTerm.cs index 17fdf9c..ef2b71e 100644 --- a/Sieve/Models/FilterTerm.cs +++ b/Sieve/Models/FilterTerm.cs @@ -4,7 +4,7 @@ using System.Text.RegularExpressions; namespace Sieve.Models { - public class FilterTerm : IFilterTerm + public class FilterTerm : IFilterTerm, IEquatable { public FilterTerm() { } @@ -76,5 +76,13 @@ namespace Sieve.Models } public bool OperatorIsCaseInsensitive { get; private set; } + + public bool Equals(FilterTerm other) + { + return Names.SequenceEqual(other.Names) + && Values.SequenceEqual(other.Values) + && Operator == other.Operator; + } + } } diff --git a/Sieve/Models/SortTerm.cs b/Sieve/Models/SortTerm.cs index 4d819b6..9299966 100644 --- a/Sieve/Models/SortTerm.cs +++ b/Sieve/Models/SortTerm.cs @@ -1,6 +1,8 @@ -namespace Sieve.Models +using System; + +namespace Sieve.Models { - public class SortTerm : ISortTerm + public class SortTerm : ISortTerm, IEquatable { public SortTerm() { } @@ -17,5 +19,11 @@ public string Name => (_sort.StartsWith("-")) ? _sort.Substring(1) : _sort; public bool Descending => _sort.StartsWith("-"); + + public bool Equals(SortTerm other) + { + return Name == other.Name + && Descending == other.Descending; + } } }