System.Web.HttpContext.Current 跟踪分析

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;
        } 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。