本文整理汇总了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;
}
示例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;
}