Exemplo n.º 1
0
        /// <summary>
        /// Adds <see cref="IHttpService"/> as <see cref="HttpService"/> to the container with interception and configuration
        /// </summary>
        public static IContainer AddHttp(this IContainer container, IHttpInterceptor httpInterceptor, Action <HttpSettings> config = null)
        {
            container.ConfigureHttp(config)
            .AddSingleton <IHttpService, HttpService>();

            container.AddSingleton(httpInterceptor);

            return(container);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public HttpService(IJsonService jsonService, ILoggingService loggingService, IHttpInterceptor httpInterceptor, HttpSettings httpSettings)
        {
            this.client = new HttpClient();
            this.Configure(httpSettings);

            // Timeout can be configured only once during the lifetime
            this.client.Timeout = TimeSpan.FromMilliseconds(httpSettings.Timeout);

            this.jsonService     = jsonService;
            this.loggingService  = loggingService;
            this.httpInterceptor = httpInterceptor;
            this.httpSettings    = httpSettings;
        }
Exemplo n.º 3
0
 public void AddInterceptor(IHttpInterceptor interceptor)
 {
     _interceptors.Add(interceptor);
 }
Exemplo n.º 4
0
 public CallAnApi WhichRequestsInterceptedBy(IHttpInterceptor interceptor)
 {
     this._interceptors.Add(interceptor);
     return(this);
 }