internal static void DisposeIdentity(Identity ident)
        {
            lock (uri_hash)
            {
                if (!ident.Disposed)
                {
                    ClientIdentity clientId = ident as ClientIdentity;
                    if (clientId != null)
                    {
                        uri_hash.Remove(GetNormalizedUri(clientId.TargetUri));
                    }
                    else
                    {
                        uri_hash.Remove(ident.ObjectUri);
                    }

                    ident.Disposed = true;
                }
            }
        }
Beispiel #2
0
		internal RealProxy (Type classToProxy, ClientIdentity identity) : this(classToProxy, IntPtr.Zero, null)
		{
			_objectIdentity = identity;
		}
Beispiel #3
0
        internal static ClientIdentity GetOrCreateClientIdentity(ObjRef objRef, Type proxyType, out object clientProxy)
        {
            // This method looks for an identity for the given url.
            // If an identity is not found, it creates the identity and
            // assigns it a proxy to the remote object.

            // Creates the client sink chain for the given url or channelData.
            // It will also get the object uri from the url.

            object channelData = objRef.ChannelInfo != null ? objRef.ChannelInfo.ChannelData : null;

            string       objectUri;
            IMessageSink sink = GetClientChannelSinkChain(objRef.URI, channelData, out objectUri);

            if (objectUri == null)
            {
                objectUri = objRef.URI;
            }

            lock (uri_hash)
            {
                clientProxy = null;
                string uri = GetNormalizedUri(objRef.URI);

                ClientIdentity identity = uri_hash [uri] as ClientIdentity;
                if (identity != null)
                {
                    // Object already registered
                    clientProxy = identity.ClientProxy;
                    if (clientProxy != null)
                    {
                        return(identity);
                    }

                    // The proxy has just been GCed, so its identity cannot
                    // be reused. Just dispose it.
                    DisposeIdentity(identity);
                }

                // Creates an identity and a proxy for the remote object

                identity             = new ClientIdentity(objectUri, objRef);
                identity.ChannelSink = sink;

                // Registers the identity
                uri_hash [uri] = identity;
                if (proxyType != null)
                {
                    RemotingProxy      proxy = new RemotingProxy(proxyType, identity);
                    CrossAppDomainSink cds   = sink as CrossAppDomainSink;
                    if (cds != null)
                    {
                        proxy.SetTargetDomain(cds.TargetDomainId);
                    }

                    clientProxy          = proxy.GetTransparentProxy();
                    identity.ClientProxy = (MarshalByRefObject)clientProxy;
                }
                return(identity);
            }
        }
Beispiel #4
0
		internal static ClientIdentity GetOrCreateClientIdentity(ObjRef objRef, Type proxyType, out object clientProxy)
		{
			// This method looks for an identity for the given url. 
			// If an identity is not found, it creates the identity and 
			// assigns it a proxy to the remote object.

			// Creates the client sink chain for the given url or channelData.
			// It will also get the object uri from the url.

			object channelData = objRef.ChannelInfo != null ? objRef.ChannelInfo.ChannelData : null;

			string objectUri;
			IMessageSink sink = GetClientChannelSinkChain (objRef.URI, channelData, out objectUri);

			if (objectUri == null) objectUri = objRef.URI;

			lock (uri_hash)
			{
				clientProxy = null;
				string uri = GetNormalizedUri (objRef.URI);
				
				ClientIdentity identity = uri_hash [uri] as ClientIdentity;
				if (identity != null)
				{
					// Object already registered
					clientProxy = identity.ClientProxy;
					if (clientProxy != null) return identity;
					
					// The proxy has just been GCed, so its identity cannot
					// be reused. Just dispose it.
					DisposeIdentity (identity);
				}

				// Creates an identity and a proxy for the remote object

				identity = new ClientIdentity (objectUri, objRef);
				identity.ChannelSink = sink;

				// Registers the identity
				uri_hash [uri] = identity;
				
				if (proxyType != null)
				{
					RemotingProxy proxy = new RemotingProxy (proxyType, identity);
					CrossAppDomainSink cds = sink as CrossAppDomainSink;
					if (cds != null)
						proxy.SetTargetDomain (cds.TargetDomainId);

					clientProxy = proxy.GetTransparentProxy();
					identity.ClientProxy = (MarshalByRefObject) clientProxy;
				}

				return identity;
			}
		}