本文整理汇总了C#中MarshalByRefObject.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# MarshalByRefObject.GetType方法的具体用法?C# MarshalByRefObject.GetType怎么用?C# MarshalByRefObject.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarshalByRefObject
的用法示例。
在下文中一共展示了MarshalByRefObject.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyProxy
public MyProxy(MarshalByRefObject
target)
: base(target.GetType())
{
this.target
=
target;
}
示例2: Marshal
public static ObjRef Marshal (MarshalByRefObject Obj, string ObjURI, Type RequestedType)
{
if (IsTransparentProxy (Obj))
{
RealProxy proxy = RemotingServices.GetRealProxy (Obj);
Identity identity = proxy.ObjectIdentity;
if (identity != null)
{
if (proxy.GetProxiedType().IsContextful && !identity.IsConnected)
{
// Unregistered local contextbound object. Register now.
ClientActivatedIdentity cboundIdentity = (ClientActivatedIdentity)identity;
if (ObjURI == null) ObjURI = NewUri();
cboundIdentity.ObjectUri = ObjURI;
RegisterServerIdentity (cboundIdentity);
cboundIdentity.StartTrackingLifetime ((ILease)Obj.InitializeLifetimeService());
return cboundIdentity.CreateObjRef (RequestedType);
}
else if (ObjURI != null)
throw new RemotingException ("It is not possible marshal a proxy of a remote object.");
ObjRef or = proxy.ObjectIdentity.CreateObjRef (RequestedType);
TrackingServices.NotifyMarshaledObject (Obj, or);
return or;
}
}
if (RequestedType == null) RequestedType = Obj.GetType ();
if (ObjURI == null)
{
if (Obj.ObjectIdentity == null)
{
ObjURI = NewUri();
CreateClientActivatedServerIdentity (Obj, RequestedType, ObjURI);
}
}
else
{
ClientActivatedIdentity identity = GetIdentityForUri ("/" + ObjURI) as ClientActivatedIdentity;
if (identity == null || Obj != identity.GetServerObject())
CreateClientActivatedServerIdentity (Obj, RequestedType, ObjURI);
}
ObjRef oref;
if (IsTransparentProxy (Obj))
oref = RemotingServices.GetRealProxy (Obj).ObjectIdentity.CreateObjRef (RequestedType);
else
oref = Obj.CreateObjRef (RequestedType);
TrackingServices.NotifyMarshaledObject (Obj, oref);
return oref;
}
示例3: InternalExecuteMessage
internal static IMethodReturnMessage InternalExecuteMessage (
MarshalByRefObject target, IMethodCallMessage reqMsg)
{
ReturnMessage result;
Type tt = target.GetType ();
MethodBase method;
if (reqMsg.MethodBase.DeclaringType == tt ||
reqMsg.MethodBase == FieldSetterMethod ||
reqMsg.MethodBase == FieldGetterMethod) {
method = reqMsg.MethodBase;
} else {
method = GetVirtualMethod (tt, reqMsg.MethodBase);
if (method == null)
throw new RemotingException (
String.Format ("Cannot resolve method {0}:{1}", tt, reqMsg.MethodName));
}
if (reqMsg.MethodBase.IsGenericMethod) {
Type[] genericArguments = reqMsg.MethodBase.GetGenericArguments ();
MethodInfo gmd = ((MethodInfo)method).GetGenericMethodDefinition ();
method = gmd.MakeGenericMethod (genericArguments);
}
object oldContext = CallContext.SetCurrentCallContext (reqMsg.LogicalCallContext);
try
{
object [] out_args;
object rval = InternalExecute (method, target, reqMsg.Args, out out_args);
// Collect parameters with Out flag from the request message
// FIXME: This can be done in the unmanaged side and will be
// more efficient
ParameterInfo[] parameters = method.GetParameters();
object[] returnArgs = new object [parameters.Length];
int n = 0;
int noa = 0;
foreach (ParameterInfo par in parameters)
{
if (par.IsOut && !par.ParameterType.IsByRef)
returnArgs [n++] = reqMsg.GetArg (par.Position);
else if (par.ParameterType.IsByRef)
returnArgs [n++] = out_args [noa++];
else
returnArgs [n++] = null;
}
result = new ReturnMessage (rval, returnArgs, n, CallContext.CreateLogicalCallContext (true), reqMsg);
}
catch (Exception e)
{
result = new ReturnMessage (e, reqMsg);
}
CallContext.RestoreCallContext (oldContext);
return result;
}