WebApplications.Utilities.Database.Configuration.DatabaseElement.GetConnections C# (CSharp) Méthode

GetConnections() private méthode

private GetConnections ( [ ensureIdentical = null, CancellationToken cancellationToken = default(CancellationToken) ) : Task>
ensureIdentical [
cancellationToken System.Threading.CancellationToken
Résultat Task>
        public Task<IEnumerable<LoadBalancedConnection>> GetConnections(
            [CanBeNull] bool? ensureIdentical = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            // ReSharper disable PossibleNullReferenceException, AssignNullToNotNullAttribute
            return Task.WhenAll(
                Connections.Select(c => c.GetLoadBalancedConnection(ensureIdentical, cancellationToken)))
                .ContinueWith(
                    t => (IEnumerable<LoadBalancedConnection>)t.Result,
                    cancellationToken,
                    TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.OnlyOnRanToCompletion,
                    TaskScheduler.Current);
            // ReSharper restore PossibleNullReferenceException, AssignNullToNotNullAttribute
        }
    }

Usage Example

Exemple #1
0
        public Task <IEnumerable <LoadBalancedConnection> > GetConnections(
            [NotNull] string database,
            [CanBeNull] bool?ensureIdentical    = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (database == null)
            {
                throw new ArgumentNullException("database");
            }

            DatabaseElement db = Databases[database];

            if ((db == null) ||
                (!db.Enabled))
            {
                return(TaskResult <IEnumerable <LoadBalancedConnection> > .FromException(
                           new LoggingException(
                               () => Resources.DatabaseConfiguration_GetSqlProgram_DatabaseIdNotFound,
                               database)));
            }

            return(db.GetConnections(ensureIdentical, cancellationToken));
        }