예제 #1
0
        public async Task InvokeAsync(IMiddlewareContext context)
        {
            await _next(context).ConfigureAwait(false);

            var pagingDetails = new PagingDetails
            {
                First  = context.ArgumentValue <int?>("first"),
                After  = context.ArgumentValue <string>("after"),
                Last   = context.ArgumentValue <int?>("last"),
                Before = context.ArgumentValue <string>("before"),
            };

            IQueryable <T> source = context.Result switch
            {
                IQueryable <T> q => q,
                IEnumerable <T> e => e.AsQueryable(),
                _ => null
            };

            if (source != null)
            {
                IConnectionResolver connectionResolver = _createConnectionResolver(
                    source, pagingDetails);

                context.Result = await connectionResolver
                                 .ResolveAsync(context.RequestAborted)
                                 .ConfigureAwait(false);
            }
        }
 public Http2SessionHandler(bool do11Handshake, HttpMessageHandler fallbackHandler, IConnectionResolver connectionResolver)
 {
     // TODO: Will we need a connection resolver that understands proxies?
     _connectionResolver = connectionResolver;
     _secureConnectionResolver = new SslConnectionResolver(_connectionResolver);
     _do11Handshake = do11Handshake;
     _11fallbackInvoker = new HttpMessageInvoker(fallbackHandler, disposeHandler: false);
     _fallbackTo11 = false;
 }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="configuration"></param>
 /// <returns></returns>
 public static IConnectionResolver Create(IConfiguration configuration)
 {
     lock (Lock)
     {
         if (_connectionResolver != null)
         {
             return(_connectionResolver);
         }
         _connectionResolver = new MockConnectionResolver(configuration);
     }
     return(_connectionResolver);
 }
예제 #4
0
        public BusClient(Guid busId, string ipAddress, int port)
        {
            _client             = new TcpClient();
            _connectionResolver = new ConnectionResolver();
            _handlers           = new Dictionary <string, Action <string> >();
            _subscriptions      = new List <string>();
            _mhs           = new MessageHandshakeSocket();
            _mhs.ServiceId = busId;

            if (IPAddress.TryParse(ipAddress, out _ipAddress) == false)
            {
                throw new NonValidIpAddressProvidedException();
            }

            _port = port;
        }
        public async Task InvokeAsync(IMiddlewareContext context)
        {
            await _next(context).ConfigureAwait(false);

            var pagingDetails = new PagingDetails
            {
                First  = context.Argument <int?>("first"),
                After  = context.Argument <string>("after"),
                Last   = context.Argument <int?>("last"),
                Before = context.Argument <string>("before"),
            };

            IQueryable <T> source = null;

            if (context.Result is PageableData <T> p)
            {
                source = p.Source;
                pagingDetails.Properties = p.Properties;
            }

            if (context.Result is IQueryable <T> q)
            {
                source = q;
            }

            if (context.Result is IEnumerable <T> e)
            {
                source = e.AsQueryable();
            }

            if (source != null)
            {
                IConnectionResolver connectionResolver = _createConnectionResolver(
                    source, pagingDetails);

                context.Result = await connectionResolver
                                 .ResolveAsync(context.RequestAborted)
                                 .ConfigureAwait(false);
            }
        }
        public async Task InvokeAsync(IMiddlewareContext context)
        {
            await _next(context).ConfigureAwait(false);

            var pagingDetails = new PaginationDetails
            {
                Limit      = context.Argument <int?>("limit"),
                PageNumber = context.Argument <int?>("pageNumber"),
            };

            IQueryable <T> source = null;

            if (context.Result is PageableData <T> p)
            {
                source = p.Source;
                pagingDetails.Properties = p.Properties;
            }

            if (context.Result is IQueryable <T> q)
            {
                source = q;
            }
            else if (context.Result is IEnumerable <T> e)
            {
                source = e.AsQueryable();
            }

            if (source != null)
            {
                IConnectionResolver connectionResolver = _createConnectionResolver(
                    source, pagingDetails);

                context.Result = await connectionResolver
                                 .ResolveAsync(context, source)
                                 .ConfigureAwait(false);
            }
        }
예제 #7
0
        private readonly IConnectionResolver <NpgsqlConnection> _resolver; //to use multipe or different provider simple dependency inject new provide

        protected BaseRepository(IOptions <ConnectionStringSettings> options, IConnectionResolver <NpgsqlConnection> resolver)
        {
            _connectionString = options.Value;
            _resolver         = resolver;
        }
예제 #8
0
 public UserRepository(IOptions <ConnectionStringSettings> options, IConnectionResolver <NpgsqlConnection> resolver) : base(options, resolver)
 {
 }
 public DisposeConnectionResolver(IConnectionResolver connectionResolver)
 {
     if (connectionResolver == null) throw new ArgumentNullException("connectionResolver");
     this.connectionResolver = connectionResolver;
 }
 public SslConnectionResolver(IConnectionResolver connectionResolver)
 {
     _connectionResolver = connectionResolver;
 }