ResilienceProperties
public sealed class ResilienceProperties : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
Represents a collection of custom resilience properties.
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace Polly
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public sealed class ResilienceProperties : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
{
[System.Runtime.CompilerServices.Nullable(new byte[] {
1,
1,
2
})]
[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>();
[System.Runtime.CompilerServices.Nullable(2)]
object IDictionary<string, object>.this[string key] {
[return: System.Runtime.CompilerServices.Nullable(2)]
get {
return Options[key];
}
[param: System.Runtime.CompilerServices.Nullable(2)]
set {
Options[key] = value;
}
}
ICollection<string> IDictionary<string, object>.Keys {
get {
return Options.Keys;
}
}
[System.Runtime.CompilerServices.Nullable(new byte[] {
1,
2
})]
ICollection<object> IDictionary<string, object>.Values {
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
2
})]
get {
return Options.Values;
}
}
int ICollection<KeyValuePair<string, object>>.Count {
get {
return Options.Count;
}
}
bool ICollection<KeyValuePair<string, object>>.IsReadOnly {
get {
return Options.IsReadOnly;
}
}
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();
}
void IDictionary<string, object>.Add(string key, [System.Runtime.CompilerServices.Nullable(2)] object value)
{
Options.Add(key, value);
}
void ICollection<KeyValuePair<string, object>>.Add([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
2
})] KeyValuePair<string, object> item)
{
Options.Add(item);
}
void ICollection<KeyValuePair<string, object>>.Clear()
{
Options.Clear();
}
bool ICollection<KeyValuePair<string, object>>.Contains([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
2
})] KeyValuePair<string, object> item)
{
return Options.Contains(item);
}
bool IDictionary<string, object>.ContainsKey(string key)
{
return Options.ContainsKey(key);
}
void ICollection<KeyValuePair<string, object>>.CopyTo([System.Runtime.CompilerServices.Nullable(new byte[] {
1,
0,
1,
2
})] KeyValuePair<string, object>[] array, int arrayIndex)
{
Options.CopyTo(array, arrayIndex);
}
[return: System.Runtime.CompilerServices.Nullable(new byte[] {
1,
0,
1,
2
})]
IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
{
return Options.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)Options).GetEnumerator();
}
bool IDictionary<string, object>.Remove(string key)
{
return Options.Remove(key);
}
bool ICollection<KeyValuePair<string, object>>.Remove([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1,
2
})] KeyValuePair<string, object> item)
{
return Options.Remove(item);
}
bool IDictionary<string, object>.TryGetValue(string key, [System.Runtime.CompilerServices.Nullable(2)] out object value)
{
return Options.TryGetValue(key, out value);
}
}
}