ResiliencePropertyKey<TValue>
Represents a key used by ResilienceProperties.
using Polly.Utils;
using System;
using System.Runtime.CompilerServices;
namespace Polly
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public readonly struct ResiliencePropertyKey<[System.Runtime.CompilerServices.Nullable(2)] TValue> : IEquatable<ResiliencePropertyKey<TValue>>
{
public string Key { get; }
public ResiliencePropertyKey(string key)
{
Guard.NotNull<string>(key, "key");
Key = key;
}
public override string ToString()
{
return Key;
}
[System.Runtime.CompilerServices.NullableContext(2)]
public override bool Equals(object obj)
{
if (obj is ResiliencePropertyKey<TValue>) {
ResiliencePropertyKey<TValue> other = (ResiliencePropertyKey<TValue>)obj;
return Equals(other);
}
return false;
}
public bool Equals([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] ResiliencePropertyKey<TValue> other)
{
return StringComparer.Ordinal.Equals(Key, other.Key);
}
public override int GetHashCode()
{
return (StringComparer.Ordinal.GetHashCode(Key), typeof(TValue)).GetHashCode();
}
public static bool operator ==([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] ResiliencePropertyKey<TValue> left, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] ResiliencePropertyKey<TValue> right)
{
return left.Equals(right);
}
public static bool operator !=([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] ResiliencePropertyKey<TValue> left, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] ResiliencePropertyKey<TValue> right)
{
return !(left == right);
}
}
}