Autofac.Integration.Web分析

using System;
using System.Web;
using Autofac.Core.Lifetime;

namespace Autofac.Integration.Web
{
    /// <summary>
    /// Provides application-wide and per-request containers.
    /// </summary>
    public class ContainerProvider : IContainerProvider
    {
        readonly IContainer _applicationContainer;
        readonly Action<ContainerBuilder> _requestLifetimeConfiguration;

        /// <summary>
        /// Initializes a new instance of the <see cref="ContainerProvider"/> class.
        /// </summary>
        /// <param name="applicationContainer">The application container.</param>
        public ContainerProvider(IContainer applicationContainer)
        {
            if (applicationContainer == null) throw new ArgumentNullException("applicationContainer");
            _applicationContainer = applicationContainer;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ContainerProvider"/> class.
        /// </summary>
        /// <param name="applicationContainer">The application container.</param>
        /// <param name="requestLifetimeConfiguration">An action that will be executed when building
        /// the per-request lifetime. The components visible within the request can be
        /// customised here.</param>
        public ContainerProvider(IContainer applicationContainer, Action<ContainerBuilder> requestLifetimeConfiguration)
            : this(applicationContainer)
        {
            if (requestLifetimeConfiguration == null) throw new ArgumentNullException("requestLifetimeConfiguration");
            _requestLifetimeConfiguration = requestLifetimeConfiguration;
        }

        /// <summary>
        /// Dispose of the current request‘s container, if it has been
        /// instantiated.
        /// </summary>
        public void EndRequestLifetime()
        {
            var rc = AmbientRequestLifetime;
            if (rc != null)
                rc.Dispose();
        }

        /// <summary>
        /// The global, application-wide container.
        /// </summary>
        /// <value></value>
        public ILifetimeScope ApplicationContainer
        {
            get
            {
                return _applicationContainer;
            }
        }

        /// <summary>
        /// The container used to manage components for processing the
        /// current request.
        /// </summary>
        /// <value></value>
        public ILifetimeScope RequestLifetime
        {
            get
            {
                var result = AmbientRequestLifetime;
                if (result == null)
                {
                    result = _requestLifetimeConfiguration == null ?
                        ApplicationContainer.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag) :
                        ApplicationContainer.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag, _requestLifetimeConfiguration);

                    AmbientRequestLifetime = result;
                }

                return result;
            }
        }

        static ILifetimeScope AmbientRequestLifetime
        {
            get
            {
                return (ILifetimeScope)HttpContext.Current.Items[typeof(ILifetimeScope)];
            }
            set
            {
                HttpContext.Current.Items[typeof(ILifetimeScope)] = value;
            }
        }
    }
}
        /// <summary>
        /// The container used to manage components for processing the
        /// current request.
        /// </summary>
        /// <value></value>
        public ILifetimeScope RequestLifetime
        {
            get
            {
                var result = AmbientRequestLifetime;
                if (result == null)
                {
                    result = _requestLifetimeConfiguration == null ?
                        ApplicationContainer.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag) :
                        ApplicationContainer.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag, _requestLifetimeConfiguration);

                    AmbientRequestLifetime = result;
                }

                return result;
            }
        }

        static ILifetimeScope AmbientRequestLifetime
        {
            get
            {
                return (ILifetimeScope)HttpContext.Current.Items[typeof(ILifetimeScope)];
            }
            set
            {
                HttpContext.Current.Items[typeof(ILifetimeScope)] = value;
            }
        }
时间: 2025-01-04 22:49:24

Autofac.Integration.Web分析的相关文章

Autofac.Integration.Mvc分析

Autofac.Integration.Mvc static ILifetimeScope LifetimeScope { get { return (ILifetimeScope)HttpContext.Current.Items[typeof(ILifetimeScope)]; } set { HttpContext.Current.Items[typeof(ILifetimeScope)] = value; } } namespace Autofac.Integration.Mvc { /

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 p

Autofac.Integration.Owin

public static IAppBuilder UseAutofacMiddleware(this IAppBuilder app, ILifetimeScope container) { if (app == null) { throw new ArgumentNullException("app"); } if (container == null) { throw new ArgumentNullException("container"); } retu

openwrt luci web分析

openwrt luci web分析 来源 https://www.jianshu.com/p/596485f95cf2 www/cbi-bin/luci #!/usr/bin/lua --cgi的执行命令的路径 require"luci.cacheloader" --导入cacheloader包 require"luci.sgi.cgi" --导入sgi.cgi包 luci.dispatcher.indexcache = "/tmp/luci-index

读了这篇文章,你将变身web分析大师

欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由shirishiyue发表于云+社区专栏 1.工具介绍 ? 这是一个非常详细且专业的web页面性能分析工具,而且开源的!如果你打不开其官网,或者担心安全问题,你可以自己拿×××这个平台工具. ? 性能分析极其详细,包含你所知道的所有新能参数指标,还有一些这个工具自己的指标参数,比如speed index,更能从人的角度看待一个页面体验是否良好.提供了多种主流浏览器的访问性能,提供了全球多个地点的测试性能,还有视频录像功能可以返回体

Sonar6.0应用之五:Sonar web分析配置

一.排除不用扫描的代码目录及文件 1.以管理员登陆Sonar,进入配置-->通用设置-->排除-->排除的源文件 二.安装需要的语言代码扫描规则 1.进入配置-->系统-->更新中心->Available 2.针对Jave开发的漏洞.违规.BUG扫描的规则可以是如下 三.配置代码扫描规则 1.进入配置-->通用设置->Java.JaveScript.SCM.技术债务根据需要进行修改,一般默认就可以. 四.质量配置,设置各个语言默认的扫描规则 五.代码规则设置

Web分析日志分析2

http://www.docin.com/p-649515490.html http://wenku.baidu.com/link?url=kB-83fbl1Zc3Y6U2BYLj-lKMWShe8ZlbFNolbuB4MO1kSMqm1TRCuRW8Rp8fvh-AH6DNBMLfV3sX_CSy238igTn3b8Pzk_8TI0zE4zoYRvO http://wenku.baidu.com/view/8b019261f5335a8102d22030.html?re=view http:/

Web分析日志

http://www.docin.com/p-649515490.html http://wenku.baidu.com/link?url=kB-83fbl1Zc3Y6U2BYLj-lKMWShe8ZlbFNolbuB4MO1kSMqm1TRCuRW8Rp8fvh-AH6DNBMLfV3sX_CSy238igTn3b8Pzk_8TI0zE4zoYRvO http://wenku.baidu.com/view/8b019261f5335a8102d22030.html?re=view http:/

ogeek线下赛web分析1-python-web

原文地址:https://www.cnblogs.com/wfzWebSecuity/p/11567207.html