示例#1
0
 public WebCaller(Client client = null, Serializer serializer = null, Logger logger = null, ClientSetting clientSetting = null, object serializerSettings = null, Type errorPayloadType = null, ErrorPayloadTypeSelector errorPayloadTypeSelector = null)
 {
     _client     = client;
     _serializer = serializer;
     _logger     = logger;
     new ClientSettingsValidator().Validate(clientSetting);
     _clientSetting            = clientSetting;
     _serializerSettings       = serializerSettings;
     _errorPayloadType         = errorPayloadType;
     _errorPayloadTypeSelector = errorPayloadTypeSelector;
     SetDefaults();
 }
示例#2
0
 private async Task Log(WebClientResponseMessage postResponse, object request, string postRequest, object response, double timeTakenInMiliseconds, ClientSetting clientSetting, string url, DateTime startTimestamp)
 {
     try
     {
         if (_logger != null)
         {
             var strResponse = string.Empty;
             if (postResponse?.Data != null)
             {
                 strResponse = clientSetting.Encoding.GetString(postResponse.Data);
             }
             await _logger.RaiseLogEvent(request, response, postRequest, strResponse, timeTakenInMiliseconds / 1000, postResponse, clientSetting.Headers, url, startTimestamp);
         }
     }
     catch (Exception exception)
     {
         throw new LoggingException("Exception occurred at the time of logging", exception);
     }
 }
示例#3
0
        public override Task <WebClientResponseMessage> GetAsync(WebClientRequestMessage request, ClientSetting clientSetting, CancellationToken cancellationToken)
        {
            var client = WebClientFactory.Create(new Settings()
            {
                TimeOut = (int)clientSetting.TimeOut.TotalMilliseconds
            });

            return(client.GetAsync(request, cancellationToken));
        }
示例#4
0
 public abstract Task <WebClientResponseMessage> GetAsync(WebClientRequestMessage request, ClientSetting clientSetting,
                                                          CancellationToken cancellationToken);
示例#5
0
 public override Task <WebClientResponseMessage> PatchAsync(WebClientRequestMessage request, ClientSetting clientSetting, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }