<PackageReference Include="Polly.Core" Version="8.0.0-alpha.9" />

ResilienceProperties

public sealed class ResilienceProperties
Represents a collection of custom resilience properties.
using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace Polly { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] [DebuggerDisplay("{Options}")] public sealed class ResilienceProperties { [System.Runtime.CompilerServices.Nullable(new byte[] { 1, 1, 2 })] [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] [field: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 1, 2 })] internal IDictionary<string, object> Options { [return: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 1, 2 })] get; [param: System.Runtime.CompilerServices.Nullable(new byte[] { 1, 1, 2 })] set; } = new Dictionary<string, object>(); public bool TryGetValue<[System.Runtime.CompilerServices.Nullable(2)] TValue>([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] ResiliencePropertyKey<TValue> key, [MaybeNullWhen(false)] out TValue value) { if (Options.TryGetValue(key.Key, out object value2) && value2 is TValue) { TValue val = value = (TValue)value2; return true; } value = default(TValue); return false; } public TValue GetValue<[System.Runtime.CompilerServices.Nullable(2)] TValue>([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] ResiliencePropertyKey<TValue> key, TValue defaultValue) { if (TryGetValue(key, out TValue value)) return value; return defaultValue; } public void Set<[System.Runtime.CompilerServices.Nullable(2)] TValue>([System.Runtime.CompilerServices.Nullable(new byte[] { 0, 1 })] ResiliencePropertyKey<TValue> key, TValue value) { Options[key.Key] = value; } internal void Replace(ResilienceProperties other) { Clear(); Dictionary<string, object> dictionary = other.Options as Dictionary<string, object>; if (dictionary != null) { foreach (KeyValuePair<string, object> item in dictionary) { Options[item.Key] = item.Value; } } else { foreach (KeyValuePair<string, object> option in other.Options) { Options[option.Key] = option.Value; } } } internal void Clear() { Options.Clear(); } } }