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


C# MarshalByRefObject类代码示例

本文整理汇总了C#中MarshalByRefObject的典型用法代码示例。如果您正苦于以下问题:C# MarshalByRefObject类的具体用法?C# MarshalByRefObject怎么用?C# MarshalByRefObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: MyProxy

    public MyProxy(MarshalByRefObject
target)
        : base(target.GetType())
    {
        this.target
        =
        target;
    }
开发者ID:robertmichaelwalsh,项目名称:CSharpFrontEnd,代码行数:8,代码来源:remoting3.cs

示例2: GetLifetimeService

	// Get a lifetime service object.
	public static Object GetLifetimeService(MarshalByRefObject obj)
			{
				if(obj == null)
				{
					return null;
				}
				return obj.GetLifetimeService();
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:RemotingServices.cs

示例3: GetRealProxy

	// Get the envoy chain for a specific proxy object.
	public static IMessageSink GetEnvoyChainForProxy
				(MarshalByRefObject obj)
			{
				if(IsObjectOutOfContext(obj))
				{
					RealProxy proxy = GetRealProxy(obj);
					Identity id = proxy.Identity;
					if(id != null)
					{
						return id.envoyChain;
					}
				}
				return null;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:15,代码来源:RemotingServices.cs

示例4: Register

	// Register an object for sponsorship.
	public bool Register(MarshalByRefObject obj)
			{
				// If there is no lease on the object, then bail out.
				ILease lease = (ILease)(obj.GetLifetimeService());
				if(lease == null)
				{
					return false;
				}

				// Inform the lease about the registered sponsor.
				lease.Register(this);
				
				// Add the lease to the sponsor table.
				lock(this)
				{
					sponsoredObjects[obj] = lease;
				}
				return true;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:20,代码来源:ClientSponsor.cs

示例5: 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;
		}
开发者ID:gustavo-melo,项目名称:mono,代码行数:55,代码来源:RemotingServices.cs

示例6: GetObjRefForProxy

		public static ObjRef GetObjRefForProxy(MarshalByRefObject obj)
		{
			Identity ident = GetObjectIdentity(obj);
			if (ident == null) return null;
			else return ident.CreateObjRef(null);
		}
开发者ID:gustavo-melo,项目名称:mono,代码行数:6,代码来源:RemotingServices.cs

示例7: GetLeaseForObject

		// Get an active lease for an object.
		public ILease GetLeaseForObject(MarshalByRefObject obj)
				{
					// TODO
					return null;
				}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:6,代码来源:LifetimeServices.cs

示例8: CreateConstructionReturnMessage

		public static IConstructionReturnMessage CreateConstructionReturnMessage (IConstructionCallMessage ctorMsg, MarshalByRefObject retObj)
		{
			return new ConstructionResponse (retObj, null, ctorMsg);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:4,代码来源:EnterpriseServicesHelper.cs

示例9: Unregister

	// Unregister an object from the sponsorship list.
	public void Unregister(MarshalByRefObject obj)
			{
				ILease lease;
				lock(this)
				{
					lease = (ILease)(sponsoredObjects[obj]);
					if(lease == null)
					{
						return;
					}
					sponsoredObjects.Remove(obj);
				}
				lease.Unregister(this);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:15,代码来源:ClientSponsor.cs

示例10: 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;
		}
开发者ID:gustavo-melo,项目名称:mono,代码行数:61,代码来源:RemotingServices.cs

示例11: GetObjectIdentity

		internal static Identity GetObjectIdentity (MarshalByRefObject obj)
		{
			if (IsTransparentProxy(obj))
				return GetRealProxy (obj).ObjectIdentity;
			else
				return obj.ObjectIdentity;
		}
开发者ID:gustavo-melo,项目名称:mono,代码行数:7,代码来源:RemotingServices.cs

示例12: DetachServer

	// Detach this proxy from a remote server.
	protected MarshalByRefObject DetachServer()
			{
				MarshalByRefObject saved = serverObject;
				serverObject = null;
				return saved;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:RealProxy.cs

示例13: InitializeLifetimeService

	// Initialize a lifetime service object for a marshal-by-ref object.
	internal static Object InitializeLifetimeService(MarshalByRefObject obj)
			{
				Manager manager = GetLifetimeManager();
				ILease lease = manager.GetLeaseForObject(obj);
				if(lease != null)
				{
					return lease;
				}
				return new Lease(obj, LeaseTime, RenewOnCallTime,
								 SponsorshipTimeout);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:12,代码来源:LifetimeServices.cs

示例14: AttachServer

	// Attach this proxy to a remote server.
	protected void AttachServer(MarshalByRefObject s)
			{
				serverObject = s;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:5,代码来源:RealProxy.cs

示例15: GetProxiedType

	public IConstructionReturnMessage InitializeServerObject
				(IConstructionCallMessage ctorMsg)
			{
				// Nothing to do if we already have a server object.
				if(serverObject != null)
				{
					return null;
				}

				// Create the server object.
				Type serverType = GetProxiedType();
				if(ctorMsg != null && ctorMsg.ActivationType != serverType)
				{
					throw new RemotingException(_("Remoting_CtorMsg"));
				}
				serverObject = (MarshalByRefObject)
					FormatterServices.GetUninitializedObject(serverType);
				if(stubData == defaultStub)
				{
					stubData = Thread.CurrentContext.ContextID;
				}
				Object proxy = GetTransparentProxy();
				if(ctorMsg == null)
				{
					// TODO: create a default constructor call message.
				}
				IMethodReturnMessage returnMessage;
				returnMessage = RemotingServices.ExecuteMessage
					((MarshalByRefObject)proxy, ctorMsg);
				return new ConstructionResponse(returnMessage);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:31,代码来源:RealProxy.cs


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