Skip to content

Commit

Permalink
Implement GetHashCode for SettingSelector (Azure#5856)
Browse files Browse the repository at this point in the history
  • Loading branch information
maririos authored Apr 22, 2019
1 parent 0c5a9ed commit 4cf4631
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Azure.Core;

namespace Azure.ApplicationModel.Configuration
{
Expand Down Expand Up @@ -131,13 +132,16 @@ private bool TagsEquals(IDictionary<string, string> other)
[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode()
{
int hash = 17;
if (Key!=null) hash = hash * 23 + Key.GetHashCode();
if (Value != null) hash = hash * 23 + Value.GetHashCode();
if (Label != null) hash = hash * 23 + Label.GetHashCode();
if (ETag != null) hash = hash * 23 + ETag.GetHashCode();
hash = hash * 23 + LastModified.GetHashCode();
return hash;
var hashCode = new HashCodeBuilder();
hashCode.Add(Key, StringComparer.Ordinal);
hashCode.Add(Label, StringComparer.Ordinal);
hashCode.Add(Value, StringComparer.Ordinal);
hashCode.Add(ContentType, StringComparer.Ordinal);
hashCode.Add(LastModified);
hashCode.Add(ETag);
hashCode.Add(Locked);
hashCode.Add(Tags);
return hashCode.ToHashCode();
}

[EditorBrowsable(EditorBrowsableState.Never)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Azure.Core;

namespace Azure.ApplicationModel.Configuration
{
Expand Down Expand Up @@ -81,7 +82,16 @@ public override bool Equals(object obj)
}

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => base.GetHashCode();
public override int GetHashCode()
{
var hashCode = new HashCodeBuilder();
hashCode.Add(Keys);
hashCode.Add(Labels);
hashCode.Add(AsOf);
hashCode.Add(Fields);
hashCode.Add(BatchLink, StringComparer.Ordinal);
return hashCode.ToHashCode();
}

[EditorBrowsable(EditorBrowsableState.Never)]
// TODO ()
Expand Down

0 comments on commit 4cf4631

Please sign in to comment.