示例#1
0
        internal static MarshalByRefObject CreateInstance(RuntimeType serverType)
        {
            MarshalByRefObject     transparentProxy = null;
            ConstructorCallMessage ctorCallMsg      = null;
            RemotingProxy          realProxy;
            bool flag = IsCurrentContextOK(serverType, null, ref ctorCallMsg);

            if (flag && !serverType.IsContextful)
            {
                return(RemotingServices.AllocateUninitializedObject(serverType));
            }
            transparentProxy = (MarshalByRefObject)ConnectIfNecessary(ctorCallMsg);
            if (transparentProxy == null)
            {
                realProxy        = new RemotingProxy(serverType);
                transparentProxy = (MarshalByRefObject)realProxy.GetTransparentProxy();
            }
            else
            {
                realProxy = (RemotingProxy)RemotingServices.GetRealProxy(transparentProxy);
            }
            realProxy.ConstructorMessage = ctorCallMsg;
            if (!flag)
            {
                ContextLevelActivator activator = new ContextLevelActivator {
                    NextActivator = ctorCallMsg.Activator
                };
                ctorCallMsg.Activator = activator;
                return(transparentProxy);
            }
            ctorCallMsg.ActivateInContext = true;
            return(transparentProxy);
        }
示例#2
0
        internal static object CheckIfConnected(RemotingProxy proxy, IConstructionCallMessage ctorMsg)
        {
            string str = (string)ctorMsg.Properties["Connect"];
            object transparentProxy = null;

            if (str != null)
            {
                transparentProxy = proxy.GetTransparentProxy();
            }
            return(transparentProxy);
        }
        internal static object CheckIfConnected(RemotingProxy proxy, IConstructionCallMessage ctorMsg)
        {
            string text   = (string)ctorMsg.Properties["Connect"];
            object result = null;

            if (text != null)
            {
                result = proxy.GetTransparentProxy();
            }
            return(result);
        }
示例#4
0
        internal static object CreateClientProxyForContextBound(Type type, object[] activationAttributes)
        {
            if (type.IsContextful)
            {
                // Look for a ProxyAttribute
                ProxyAttribute att = (ProxyAttribute)Attribute.GetCustomAttribute(type, typeof(ProxyAttribute), true);
                if (att != null)
                {
                    return(att.CreateInstance(type));
                }
            }
            RemotingProxy proxy = new RemotingProxy(type, ChannelServices.CrossContextUrl, activationAttributes);

            return(proxy.GetTransparentProxy());
        }
示例#5
0
        internal static object CreateClientProxy(Type objectType, string url, object[] activationAttributes)
        {
            string activationUrl = url;

            if (!activationUrl.EndsWith("/"))
            {
                activationUrl += "/";
            }
            activationUrl += "RemoteActivationService.rem";

            string objectUri;

            GetClientChannelSinkChain(activationUrl, null, out objectUri);

            RemotingProxy proxy = new RemotingProxy(objectType, activationUrl, activationAttributes);

            return(proxy.GetTransparentProxy());
        }
示例#6
0
        internal static MarshalByRefObject CreateInstance(RuntimeType serverType)
        {
            ConstructorCallMessage ctorCallMsg = (ConstructorCallMessage)null;
            bool flag = ActivationServices.IsCurrentContextOK(serverType, (object[])null, ref ctorCallMsg);
            MarshalByRefObject marshalByRefObject;

            if (flag && !serverType.IsContextful)
            {
                marshalByRefObject = RemotingServices.AllocateUninitializedObject(serverType);
            }
            else
            {
                marshalByRefObject = (MarshalByRefObject)ActivationServices.ConnectIfNecessary((IConstructionCallMessage)ctorCallMsg);
                RemotingProxy remotingProxy;
                if (marshalByRefObject == null)
                {
                    remotingProxy      = new RemotingProxy((Type)serverType);
                    marshalByRefObject = (MarshalByRefObject)remotingProxy.GetTransparentProxy();
                }
                else
                {
                    remotingProxy = (RemotingProxy)RemotingServices.GetRealProxy((object)marshalByRefObject);
                }
                remotingProxy.ConstructorMessage = ctorCallMsg;
                if (!flag)
                {
                    ctorCallMsg.Activator = (IActivator) new ContextLevelActivator()
                    {
                        NextActivator = ctorCallMsg.Activator
                    }
                }
                ;
                else
                {
                    ctorCallMsg.ActivateInContext = true;
                }
            }
            return(marshalByRefObject);
        }
示例#7
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);
            }
        }