From 2eab18dc76dcf20f1c528fd1d63be61090f8e832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 17 May 2021 17:46:13 +0200 Subject: [PATCH] CacheKey uses only UserAgent for Equals and GetHashCode --- .../HttpUserAgentParserMemoryCachedProvider.cs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/MyCSharp.HttpUserAgentParser.MemoryCache/HttpUserAgentParserMemoryCachedProvider.cs b/src/MyCSharp.HttpUserAgentParser.MemoryCache/HttpUserAgentParserMemoryCachedProvider.cs index f618c5f..7ebf9d8 100644 --- a/src/MyCSharp.HttpUserAgentParser.MemoryCache/HttpUserAgentParserMemoryCachedProvider.cs +++ b/src/MyCSharp.HttpUserAgentParser.MemoryCache/HttpUserAgentParserMemoryCachedProvider.cs @@ -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(); } } }