Exemplo n.º 1
0
        internal BardHttpClient(EventAggregator eventAggregator, BardResponsePublisher messageHandler,
                                IBadRequestProvider badRequestProvider, LogWriter logWriter) : base(
                messageHandler)
        {
            messageHandler.PublishApiResult = NotifyObservers;

            EventAggregator = eventAggregator;
            RequestProvider = badRequestProvider;
            Writer          = logWriter;
        }
Exemplo n.º 2
0
        private static BardHttpClient CloneHttpClient(HttpClient client, LogWriter logWriter,
                                                      IBadRequestProvider badRequestProvider, EventAggregator eventAggregator,
                                                      BardResponsePublisher bardResponsePublisher)
        {
            var bardHttpClient = new BardHttpClient(eventAggregator, bardResponsePublisher, badRequestProvider, logWriter)
            {
                BaseAddress = client.BaseAddress,
                Timeout     = client.Timeout,
                MaxResponseContentBufferSize = client.MaxResponseContentBufferSize
            };

            foreach (var(key, value) in client.DefaultRequestHeaders)
            {
                bardHttpClient.DefaultRequestHeaders.TryAddWithoutValidation(key, value);
            }

            return(bardHttpClient);
        }
Exemplo n.º 3
0
        internal static BardHttpClient CreateRequestLoggingClient(HttpClient client, LogWriter logWriter,
                                                                  IBadRequestProvider badRequestProvider, EventAggregator eventAggregator)
        {
            var httpMessageHandler = GetInstanceField(client);

            if (httpMessageHandler == null)
            {
                throw new BardException("Cannot find client handler");
            }

            var grpcMessageHandler          = new GrpcMessageHandler(httpMessageHandler);
            var requestLoggerMessageHandler = new RequestLoggerMessageHandler(logWriter, grpcMessageHandler);
            var bardResponsePublisher       = new BardResponsePublisher(requestLoggerMessageHandler);

            var bardHttpClient = CloneHttpClient(client, logWriter, badRequestProvider, eventAggregator, bardResponsePublisher);

            return(bardHttpClient);
        }