예제 #1
0
        /// <summary>
        /// Creates a provider implementation
        /// </summary>
        /// <param name="dependencyParams">Dependency monitoring parameters</param>
        /// <param name="providerType">Type of the provider to create</param>
        /// <param name="serviceBrokerQueue">Queue name for the service broker implementation</param>
        /// <param name="periodForPollingProvider">Period for polling implementation</param>
        /// <returns>Sql Dependency Provider instance</returns>
        public static SqlDependencyProvider Create(SqlDependencyParams dependencyParams,
                                                   SqlDependencyProviderType providerType,
                                                   string serviceBrokerQueue, TimeSpan?periodForPollingProvider)
        {
            // Validate
            if (dependencyParams == null)
            {
                throw new ArgumentNullException(nameof(dependencyParams));
            }
            if (periodForPollingProvider.HasValue &&
                (periodForPollingProvider.Value.TotalMilliseconds < 0))
            {
                throw new ArgumentNullException(nameof(periodForPollingProvider));
            }
            serviceBrokerQueue = string.IsNullOrWhiteSpace(serviceBrokerQueue) ? null : serviceBrokerQueue.Trim();

            // Make a copy & validate
            dependencyParams = dependencyParams.Clone() as SqlDependencyParams;
            if (dependencyParams == null)
            {
                throw new ArgumentNullException(nameof(dependencyParams));
            }
            dependencyParams.ValidateAndAdjust();

            // Check service broker availability
            if ((providerType == SqlDependencyProviderType.Polling) ||
                ((providerType == SqlDependencyProviderType.Auto) &&
                 !IsServiceBrokerEnabled(dependencyParams.ConnectionString, serviceBrokerQueue)))
            {
                return(new PollingSqlDependencyProvider(dependencyParams, periodForPollingProvider));
            }
            return(new BrokerSqlDependencyProvider(dependencyParams));
        }
예제 #2
0
 /// <summary>
 /// Creates a provider implementation
 /// </summary>
 /// <param name="dependencyParams">Dependency monitoring parameters</param>
 /// <param name="providerType">Type of the provider to create</param>
 /// <param name="serviceBrokerQueue">Queue name for the service broker implementation</param>
 /// <returns>Sql Dependency Provider instance</returns>
 public static SqlDependencyProvider Create(SqlDependencyParams dependencyParams,
                                            SqlDependencyProviderType providerType, string serviceBrokerQueue)
 {
     return(Create(dependencyParams, providerType, serviceBrokerQueue, null));
 }
예제 #3
0
 /// <summary>
 /// Creates a provider implementation
 /// </summary>
 /// <param name="dependencyParams">Dependency monitoring parameters</param>
 /// <param name="providerType">Type of the provider to create</param>
 /// <returns>Sql Dependency Provider instance</returns>
 public static SqlDependencyProvider Create(SqlDependencyParams dependencyParams,
                                            SqlDependencyProviderType providerType)
 {
     return(Create(dependencyParams, providerType, null, null));
 }
        /// <summary>
        /// Creates a provider implementation
        /// </summary>
        /// <param name="dependencyParams">Dependency monitoring parameters</param>
        /// <param name="providerType">Type of the provider to create</param>
        /// <param name="serviceBrokerQueue">Queue name for the service broker implementation</param>
        /// <param name="periodForPollingProvider">Period for polling implementation</param>
        /// <returns>Sql Dependency Provider instance</returns>
        public static SqlDependencyProvider Create(SqlDependencyParams dependencyParams,
			SqlDependencyProviderType providerType,
			string serviceBrokerQueue, TimeSpan? periodForPollingProvider)
        {
            // Validate
            if (dependencyParams == null)
            {
                throw new ArgumentNullException(nameof(dependencyParams));
            }
            if (periodForPollingProvider.HasValue
                && (periodForPollingProvider.Value.TotalMilliseconds < 0))
            {
                throw new ArgumentNullException(nameof(periodForPollingProvider));
            }
            serviceBrokerQueue = string.IsNullOrWhiteSpace(serviceBrokerQueue) ? null : serviceBrokerQueue.Trim();

            // Make a copy & validate
            dependencyParams = dependencyParams.Clone() as SqlDependencyParams;
            if (dependencyParams == null)
            {
                throw new ArgumentNullException(nameof(dependencyParams));
            }
            dependencyParams.ValidateAndAdjust();

            // Check service broker availability
            if ((providerType == SqlDependencyProviderType.Polling)
                || ((providerType == SqlDependencyProviderType.Auto)
                    && !IsServiceBrokerEnabled(dependencyParams.ConnectionString, serviceBrokerQueue)))
            {
                return new PollingSqlDependencyProvider(dependencyParams, periodForPollingProvider);
            }
            return new BrokerSqlDependencyProvider(dependencyParams);
        }
        /// <summary>
        /// Creates a provider implementation
        /// </summary>
        /// <param name="dependencyParams">Dependency monitoring parameters</param>
        /// <param name="providerType">Type of the provider to create</param>
        /// <param name="serviceBrokerQueue">Queue name for the service broker implementation</param>
        /// <returns>Sql Dependency Provider instance</returns>
        public static SqlDependencyProvider Create(SqlDependencyParams dependencyParams,
			SqlDependencyProviderType providerType, string serviceBrokerQueue)
        {
            return Create(dependencyParams, providerType, serviceBrokerQueue, null);
        }
        /// <summary>
        /// Creates a provider implementation
        /// </summary>
        /// <param name="dependencyParams">Dependency monitoring parameters</param>
        /// <param name="providerType">Type of the provider to create</param>
        /// <returns>Sql Dependency Provider instance</returns>
        public static SqlDependencyProvider Create(SqlDependencyParams dependencyParams,
			SqlDependencyProviderType providerType)
        {
            return Create(dependencyParams, providerType, null, null);
        }