Skip to content

CacheKey uses only UserAgent for Equals and GetHashCode #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2021
Merged
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
Expand Up @@ -50,20 +50,10 @@ private CacheKey GetKey(string userAgent)

public HttpUserAgentParserMemoryCachedProviderOptions Options { get; set; } = null!;

public bool Equals(CacheKey? other)
{
if (ReferenceEquals(this, other)) return true;
if (other is null) return false;

return this.UserAgent == other.UserAgent && this.Options == other.Options;
}

public override bool Equals(object? obj)
{
return this.Equals(obj as CacheKey);
}
public bool Equals(CacheKey? other) => this.UserAgent == other?.UserAgent;
public override bool Equals(object? obj) => this.Equals(obj as CacheKey);

public override int GetHashCode() => HashCode.Combine(this.UserAgent, this.Options);
public override int GetHashCode() => this.UserAgent.GetHashCode();
}
}
}