当前位置: 首页>>代码示例>>C#>>正文


C# ObjRef.GetServerContext方法代码示例

本文整理汇总了C#中System.Runtime.Remoting.ObjRef.GetServerContext方法的典型用法代码示例。如果您正苦于以下问题:C# ObjRef.GetServerContext方法的具体用法?C# ObjRef.GetServerContext怎么用?C# ObjRef.GetServerContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Runtime.Remoting.ObjRef的用法示例。


在下文中一共展示了ObjRef.GetServerContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetServerContextForProxy

        [System.Security.SecurityCritical]  // auto-generated 
        private static IntPtr GetServerContextForProxy( 
            Object tp, out ObjRef objRef, out bool bSameDomain, out int domainId)
        { 
            // Note: the contextId we return from here should be the address
            // of the unmanaged (VM) context object or NULL.

            IntPtr contextId = IntPtr.Zero; 
            objRef = null;
            bSameDomain = false; 
            domainId = 0; 
            if (IsTransparentProxy(tp))
            { 
                // This is a transparent proxy. Try to obtain the backing
                // RealProxy from it.
                RealProxy rp = GetRealProxy(tp);
 
                // Get the identity from the realproxy
                Identity id = rp.IdentityObject; 
                if(null != id) 
                {
                    ServerIdentity serverID = id as ServerIdentity; 
                    if (null != serverID)
                    {
                        // We are in the app domain of the server
                        bSameDomain = true; 
                        contextId = serverID.ServerContext.InternalContextID;
                        domainId = Thread.GetDomain().GetId(); 
                    } 
                    else
                    { 
                        // Server is from another app domain
                        // (possibly from another process)
                        objRef = id.ObjectRef;
                        if (objRef != null) 
                        {
                            contextId = objRef.GetServerContext(out domainId); 
                        } 
                        else
                        { 
                            // Proxy does not have an associated ObjRef
                            // <

 

                            //Contract.Assert(false, "Found proxy without an objref"); 
                            contextId = IntPtr.Zero; 
                        }
                    } 
                }
                else
                {
                    // This was probably a custom proxy other than RemotingProxy 
                    Contract.Assert(
                        !(rp is RemotingProxy), 
                        "!(rp is RemotingProxy)"); 

                    contextId = Context.DefaultContext.InternalContextID; 
                }
            }

            return contextId; 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:63,代码来源:RemotingServices.cs

示例2: GetServerContextForProxy

 private static IntPtr GetServerContextForProxy(object tp, out ObjRef objRef, out bool bSameDomain, out int domainId)
 {
     IntPtr zero = IntPtr.Zero;
     objRef = null;
     bSameDomain = false;
     domainId = 0;
     if (!IsTransparentProxy(tp))
     {
         return zero;
     }
     Identity identityObject = GetRealProxy(tp).IdentityObject;
     if (identityObject != null)
     {
         ServerIdentity identity2 = identityObject as ServerIdentity;
         if (identity2 != null)
         {
             bSameDomain = true;
             zero = identity2.ServerContext.InternalContextID;
             domainId = Thread.GetDomain().GetId();
             return zero;
         }
         objRef = identityObject.ObjectRef;
         if (objRef != null)
         {
             return objRef.GetServerContext(out domainId);
         }
         return IntPtr.Zero;
     }
     return Context.DefaultContext.InternalContextID;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:RemotingServices.cs


注:本文中的System.Runtime.Remoting.ObjRef.GetServerContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。