public static IHttpContextBuilder UseOwinEnvironment(
     this IHttpContextBuilder builder,
     Func <IServiceProvider, IDictionary <string, object> > environmentFactory,
     ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
 {
     return(builder.UseOwin(provider => new OwinContext(environmentFactory(provider)), serviceLifetime));
 }
 public static IHttpContextBuilder UseOwinFromHttpContext(
     this IHttpContextBuilder builder,
     Func <IServiceProvider, HttpContextBase> httpContextFactory,
     ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
 {
     return(builder.UseOwin(provider => httpContextFactory(provider).GetOwinContext(), serviceLifetime));
 }