<PackageReference Include="Polly" Version="6.1.1" />

PolicyBase

public abstract class PolicyBase
Implements elements common to both non-generic Policy and generic Policy<T>
using Polly.Utilities; using System; using System.Collections.Generic; using System.Threading; namespace Polly { public abstract class PolicyBase { protected string policyKeyInternal; protected internal static CancellationToken DefaultCancellationToken = CancellationToken.None; protected internal static bool DefaultContinueOnCapturedContext = false; public string PolicyKey => policyKeyInternal ?? (policyKeyInternal = GetType().Name + "-" + KeyHelper.GuidPart()); internal static ArgumentException PolicyKeyMustBeImmutableException => new ArgumentException("PolicyKey cannot be changed once set; or (when using the default value after the PolicyKey property has been accessed.", "policyKey"); protected internal IEnumerable<ExceptionPredicate> ExceptionPredicates { get; set; } internal virtual void SetPolicyContext(Context executionContext, out string priorPolicyWrapKey, out string priorPolicyKey) { priorPolicyWrapKey = executionContext.PolicyWrapKey; priorPolicyKey = executionContext.PolicyKey; executionContext.PolicyKey = PolicyKey; } internal void RestorePolicyContext(Context executionContext, string priorPolicyWrapKey, string priorPolicyKey) { executionContext.PolicyWrapKey = priorPolicyWrapKey; executionContext.PolicyKey = priorPolicyKey; } } }