• 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;
            } 
  • 相关阅读:
    2019浙江理工校赛有感
    问题 G: 跳马棋
    问题 H: 象棋对局胜负
    问题 C: 远离原点
    问题 B: 合并车厢
    Hibernate 异常汇总
    设计模式
    1.2.1.2.1.12.34.3.1.34.1.2
    数据结构和算法之 查找
    数据结构和算法之排序算法
  • 原文地址:https://www.cnblogs.com/zbw911/p/4259007.html
Copyright © 2020-2023  润新知