protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { ExchangeId exchangeId = ExchangeId.NewExchangeId(); if (StoreExchangeId) { request.Properties[ExchangeIdPropertyKey] = exchangeId; } await _logger.LogAsync(exchangeId, request, cancellationToken).ConfigureAwait(false); HttpResponseMessage response; try { response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false); } catch (Exception e) { await _logger.LogAsync(exchangeId, e, cancellationToken).ConfigureAwait(false); throw; } await _logger.LogAsync(exchangeId, response, cancellationToken).ConfigureAwait(false); return(response); }
public override bool Equals(object obj) { if (!(obj is ExchangeId)) { return(false); } ExchangeId other = (ExchangeId)obj; return(When.Equals(other.When) && Unique.Equals(other.Unique)); }
public static bool TryGetExchangeId(this HttpRequestMessage request, out ExchangeId exchangeId) { object value; if (request.Properties.TryGetValue(LoggingHandler.ExchangeIdPropertyKey, out value) && value is ExchangeId) { exchangeId = (ExchangeId)value; return(true); } exchangeId = default(ExchangeId); return(false); }