示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
        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);
        }