/// <summary> /// Initializes a new instance of the <see cref="LoadBalancedConnection"/> class. /// </summary> /// <param name="databaseId">The database identifier.</param> /// <param name="connectionId">The connection identifier.</param> /// <param name="connectionStrings">The connection strings.</param> /// <exception cref="System.ArgumentNullException">connectionStrings</exception> internal LoadBalancedConnection( [NotNull] string databaseId, [NotNull] string connectionId, [NotNull] IEnumerable <KeyValuePair <string, double> > connectionStrings) // ReSharper disable once AssignNullToNotNullAttribute : this(connectionStrings .Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key)) // ReSharper disable AssignNullToNotNullAttribute .Select(kvp => new Connection(databaseId, connectionId, kvp.Key, kvp.Value))) // ReSharper restore AssignNullToNotNullAttribute { if (databaseId == null) { throw new ArgumentNullException(nameof(databaseId)); } if (connectionId == null) { throw new ArgumentNullException(nameof(connectionId)); } if (connectionStrings == null) { throw new ArgumentNullException(nameof(connectionStrings)); } DatabaseId = databaseId; DatabaseSemaphore = ConcurrencyController.GetDatabaseSemaphore(databaseId); ConnectionSemaphore = ConcurrencyController.GetLoadBalancedConnectionSemaphore(databaseId, connectionId); }
/// <summary> /// Initializes a new instance of the <see cref="Connection"/> class. /// </summary> /// <param name="databseId">The databse identifier.</param> /// <param name="lbConnectionId">The lb connection identifier.</param> /// <param name="connectionString">The connection string.</param> /// <param name="weight">The weight.</param> /// <exception cref="System.ArgumentNullException"> /// </exception> internal Connection( [NotNull] string databseId, [NotNull] string lbConnectionId, [NotNull] string connectionString, double weight) : this(connectionString, weight) { if (databseId == null) { throw new ArgumentNullException(nameof(databseId)); } if (lbConnectionId == null) { throw new ArgumentNullException(nameof(lbConnectionId)); } Semaphore = ConcurrencyController.GetConnectionSemaphore(databseId, lbConnectionId, this); }