zoukankan      html  css  js  c++  java
  • Autofac.Integration.Mvc.Owin分析

    using System;
    using System.ComponentModel;
    using System.Diagnostics.CodeAnalysis;
    using System.Security;
    using System.Web;
    using Autofac;
    using Autofac.Integration.Owin;
    
    namespace Owin
    {
        /// <summary>
        /// Extension methods for configuring the OWIN pipeline.
        /// </summary>
        [SecuritySafeCritical]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public static class AutofacMvcAppBuilderExtensions
        {
            internal static Func<HttpContextBase> CurrentHttpContext = () => new HttpContextWrapper(HttpContext.Current);
    
            /// <summary>
            /// Extends the Autofac lifetime scope added from the OWIN pipeline through to the MVC request lifetime scope.
            /// </summary>
            /// <param name="app">The application builder.</param>
            /// <returns>The application builder.</returns>
            [SecuritySafeCritical]
            [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
            public static IAppBuilder UseAutofacMvc(this IAppBuilder app)
            {
                return app.Use(async (context, next) =>
                {
                    var lifetimeScope = context.GetAutofacLifetimeScope();
                    var httpContext = CurrentHttpContext();
    
                    if (lifetimeScope != null && httpContext != null)
                        httpContext.Items[typeof(ILifetimeScope)] = lifetimeScope;
    
                    await next();
                });
            }
        }
    }
  • 相关阅读:
    css文档流
    gitolite搭建
    Packets out of order. Expected 1 received 27...
    前端常见跨域解决方案
    跨时代的分布式数据库 – 阿里云DRDS详解
    Redis持久化机制
    redis实现消息队列
    队列
    ide-helper
    Bitmap 位操作相关
  • 原文地址:https://www.cnblogs.com/shiningrise/p/5568881.html
Copyright © 2011-2022 走看看