示例#1
0
 private static string GetProviderType(SqlRetryPolicyProvider provider)
 {
     if (provider == null)
     {
         return("null");
     }
     return(provider.GetType().FullName);
 }
示例#2
0
        /// <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);
        }
示例#3
0
 /// <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));
 }