• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MarshalByRefObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetUrlsForObject

	public static String[] GetUrlsForObject(MarshalByRefObject obj)
			{
				// TODO
				return null;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:5,代码来源:ChannelServices.cs


示例17: GetEnvoyChainForProxy

		public static IMessageSink GetEnvoyChainForProxy (MarshalByRefObject obj)
		{
			if (IsTransparentProxy(obj))
				return ((ClientIdentity)GetRealProxy (obj).ObjectIdentity).EnvoySink;
			else
				throw new ArgumentException ("obj must be a proxy.","obj");			
		}
开发者ID:gustavo-melo,项目名称:mono,代码行数:7,代码来源:RemotingServices.cs


示例18: ExecuteMessage

		public static IMethodReturnMessage ExecuteMessage (
			MarshalByRefObject target, IMethodCallMessage reqMsg)
		{
			if (IsTransparentProxy(target))
			{
				// Message must go through all chain of sinks
				RealProxy rp = GetRealProxy (target);
				return (IMethodReturnMessage) rp.Invoke (reqMsg);
			}
			else	// Direct call
				return InternalExecuteMessage (target, reqMsg);
		}
开发者ID:gustavo-melo,项目名称:mono,代码行数:12,代码来源:RemotingServices.cs


示例19: SetObjectUriForMarshal

		public static void SetObjectUriForMarshal(MarshalByRefObject obj, string uri)
		{
			if (IsTransparentProxy (obj)) {
				RealProxy proxy = RemotingServices.GetRealProxy(obj);
				Identity identity = proxy.ObjectIdentity;

				if (identity != null && !(identity is ServerIdentity) && !proxy.GetProxiedType().IsContextful)
					throw new RemotingException ("SetObjectUriForMarshal method should only be called for MarshalByRefObjects that exist in the current AppDomain.");
			}
			
			Marshal (obj, uri);
		}
开发者ID:gustavo-melo,项目名称:mono,代码行数:12,代码来源:RemotingServices.cs


示例20: CreateServerObjectSinkChain

		internal IMessageSink CreateServerObjectSinkChain (MarshalByRefObject obj, bool forceInternalExecute)
		{
			IMessageSink objectSink = new StackBuilderSink (obj, forceInternalExecute);
			objectSink = new ServerObjectTerminatorSink (objectSink);
			objectSink = new Lifetime.LeaseSink (objectSink);

			if (context_properties != null)
			{
				// Contribute object sinks in reverse order
				for (int n = context_properties.Count-1; n >= 0; n--)
				{
					IContextProperty prop = (IContextProperty) context_properties[n];
					IContributeObjectSink contributor = prop as IContributeObjectSink;
					if (contributor != null)
						objectSink = contributor.GetObjectSink (obj, objectSink);
				}
			}
			return objectSink;
		}
开发者ID:psni,项目名称:mono,代码行数:19,代码来源:Context.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MarshalledImage类代码示例发布时间:2022-05-24
下一篇:
C# MarkovMultivariateFunction类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap