private static string GetProviderType(SqlRetryPolicyProvider provider) { if (provider == null) { return("null"); } return(provider.GetType().FullName); }
/// <summary> /// Set an authentication provider by method. /// </summary> /// <param name="provider">Authentication provider.</param> /// <param name="sqlRetryLogicMethod">Authentication provider.</param> /// <returns>True if succeeded, false otherwise, e.g., the existing provider disallows overriding.</returns> public bool SetProvider(SqlRetryPolicyProvider provider, SqlRetryLogicMethod sqlRetryLogicMethod) { if (!provider.IsSupported(sqlRetryLogicMethod)) { throw SQL.UnsupportedAuthenticationByProvider("", provider.GetType().Name); } _providers.AddOrUpdate(sqlRetryLogicMethod, provider, (key, oldProvider) => { if (oldProvider != null) { oldProvider.BeforeUnload(sqlRetryLogicMethod); } if (provider != null) { provider.BeforeLoad(sqlRetryLogicMethod); } return(provider); }); return(true); }
/// <summary> /// /// </summary> /// <param name="reliabilityMethod"></param> /// <param name="provider"></param> /// <returns></returns> public static bool SetProvider(SqlRetryLogicMethod reliabilityMethod, SqlRetryPolicyProvider provider) { return(SqlRetryPolicyProviderManager.Instance.SetProvider(provider, reliabilityMethod)); }