public void ContextResolverSetClear() { var ctx = new TestContext { CorrelationId = "1", OtherId = "2" }; ContextResolver.SetRequestContext(ctx); ContextResolver.ClearContext(); Assert.Null(ContextResolver.GetRequestContext <TestContext>()); }
public async Task Invoke(IDictionary <string, object> environment) { try { var ctx = contextFactory.CreateContext(environment); ContextResolver.SetRequestContext(ctx); await next.Invoke(environment).ConfigureAwait(false); } finally { ContextResolver.ClearContext(); } }
public async Task Invoke(HttpContext context) { var ctx = default(TContext); try { ctx = contextFactory.CreateContext(context.Request); ContextResolver.SetRequestContext(ctx); await next.Invoke(context).ConfigureAwait(false); } finally { if (ctx != null) { ContextResolver.ClearContext(); } } }