码迷,mamicode.com
首页 > Web开发 > 详细

System.Web.HttpContext.Current 跟踪分析

时间:2015-01-29 11:54:05      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

public static HttpContext Current
    {
      get
      {
        return ContextBase.Current as HttpContext;
      }
      set
      {
        ContextBase.Current = (object) value;
      }
    }

 

 internal class ContextBase
  {
    internal static object Current
    {
      get
      {
        return CallContext.HostContext;
      }
      [SecurityPermission(SecurityAction.Demand, Unrestricted = true)] set
      {
        CallContext.HostContext = value;
      }
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    public ContextBase()
    {
    }

    internal static object SwitchContext(object newContext)
    {
      object hostContext = CallContext.HostContext;
      if (hostContext != newContext)
        CallContext.HostContext = newContext;
      return hostContext;
    }
  }

 

 public static Object HostContext 
        {
            [System.Security.SecurityCritical]  // auto-generated
            get
            { 
                Object hC;
                IllogicalCallContext ilcc = Thread.CurrentThread.GetIllogicalCallContext(); 
                hC = ilcc.HostContext; 
                if (hC == null)
                { 
                    LogicalCallContext lcc = GetLogicalCallContext();
                    hC = lcc.HostContext;
                }
                return hC; 
            }
            [System.Security.SecurityCritical]  // auto-generated_required 
            set 
            {
                if (value is ILogicalThreadAffinative) 
                {
                    IllogicalCallContext ilcc = Thread.CurrentThread.GetIllogicalCallContext();
                    ilcc.HostContext = null;
                    LogicalCallContext lcc = GetLogicalCallContext(); 
                    lcc.HostContext = value;
                } 
                else 
                {
                    LogicalCallContext lcc = GetLogicalCallContext(); 
                    lcc.HostContext = null;
                    IllogicalCallContext ilcc = Thread.CurrentThread.GetIllogicalCallContext();
                    ilcc.HostContext = value;
                } 
            }
        } 

 

        internal IllogicalCallContext GetIllogicalCallContext() 
        { 
            return ExecutionContext.IllogicalCallContext;
        } 

System.Web.HttpContext.Current 跟踪分析

标签:

原文地址:http://www.cnblogs.com/zbw911/p/4259007.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!