本文整理汇总了C#中System.Runtime.Remoting.Proxies.RealProxy.GetTransparentProxy方法的典型用法代码示例。如果您正苦于以下问题:C# RealProxy.GetTransparentProxy方法的具体用法?C# RealProxy.GetTransparentProxy怎么用?C# RealProxy.GetTransparentProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.Remoting.Proxies.RealProxy
的用法示例。
在下文中一共展示了RealProxy.GetTransparentProxy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SwitchWrappers
public static void SwitchWrappers(RealProxy oldcp, RealProxy newcp)
{
object transparentProxy = oldcp.GetTransparentProxy();
object tp = newcp.GetTransparentProxy();
RemotingServices.GetServerContextForProxy(transparentProxy);
RemotingServices.GetServerContextForProxy(tp);
Marshal.InternalSwitchCCW(transparentProxy, tp);
}
示例2: SwitchWrappers
[System.Security.SecurityCritical] // auto-generated_required
public static void SwitchWrappers(RealProxy oldcp, RealProxy newcp)
{
Object oldtp = oldcp.GetTransparentProxy();
Object newtp = newcp.GetTransparentProxy();
IntPtr oldcontextId = RemotingServices.GetServerContextForProxy(oldtp);
IntPtr newcontextId = RemotingServices.GetServerContextForProxy(newtp);
// switch the CCW from oldtp to new tp
Marshal.InternalSwitchCCW(oldtp, newtp);
}
示例3: CheckCast
[System.Security.SecurityCritical] // auto-generated
private static bool CheckCast(RealProxy rp, RuntimeType castType)
{
// NOTE: This is the point where JIT_CheckCastClass ultimately
// lands up in the managed world if the object being cast is
// a transparent proxy.
// If we are here, it means that walking the current EEClass
// up the chain inside the EE was unable to verify the cast.
Message.DebugOut("Entered CheckCast for type " + castType);
bool fCastOK = false;
BCLDebug.Assert(rp != null, "Shouldn't be called with null real proxy.");
// Always return true if cast is to System.Object
if (castType == typeof(Object))
return true;
// We do not allow casting to non-interface types that do not extend
// from System.MarshalByRefObject
if (!castType.IsInterface && !castType.IsMarshalByRef)
return false;
// Note: this is a bit of a hack to allow deserialization of WellKnown
// object refs (in the well known cases, we always return TRUE for
// interface casts but doing so messes us up in the case when
// the object manager is trying to resolve object references since
// it ends up thinking that the proxy we returned needs to be resolved
// further).
if (castType != typeof(IObjectReference))
{
IRemotingTypeInfo typeInfo = rp as IRemotingTypeInfo;
if(null != typeInfo)
{
fCastOK = typeInfo.CanCastTo(castType, rp.GetTransparentProxy());
}
else
{
// The proxy does not implement IRemotingTypeInfo, so we should
// try to do casting based on the ObjRef type info.
Identity id = rp.IdentityObject;
if (id != null)
{
ObjRef objRef = id.ObjectRef;
if (objRef != null)
{
typeInfo = objRef.TypeInfo;
if (typeInfo != null)
{
fCastOK = typeInfo.CanCastTo(castType, rp.GetTransparentProxy());
}
}
}
}
}
Message.DebugOut("CheckCast returning " + fCastOK);
return fCastOK;
}
示例4: CheckCast
private static bool CheckCast(RealProxy rp, RuntimeType castType)
{
bool flag = false;
if (castType == typeof(object))
{
return true;
}
if (!castType.IsInterface && !castType.IsMarshalByRef)
{
return false;
}
if (castType != typeof(IObjectReference))
{
IRemotingTypeInfo typeInfo = rp as IRemotingTypeInfo;
if (typeInfo != null)
{
return typeInfo.CanCastTo(castType, rp.GetTransparentProxy());
}
Identity identityObject = rp.IdentityObject;
if (identityObject != null)
{
ObjRef objectRef = identityObject.ObjectRef;
if (objectRef != null)
{
typeInfo = objectRef.TypeInfo;
if (typeInfo != null)
{
flag = typeInfo.CanCastTo(castType, rp.GetTransparentProxy());
}
}
}
}
return flag;
}