示例#1
0
        private void UISubmit_Click(object sender, EventArgs e)
        {
            if (TryGetSelectedId(out ServerIdentity id))
            {
                SelectedID  = id;
                music       = TagLib.File.Create(FilesPath[0]);
                AlbumToSend = new Album(music.Tag.Album);

                foreach (var p in FilesPath)
                {
                    music = TagLib.File.Create(p);
                    var tmpFile     = TagLib.File.Create(p);
                    var MusicUpload = new Music(tmpFile.Tag.Title, new Author(tmpFile.Tag.Performers[0]), new Album(AlbumToSend.Name), System.IO.File.ReadAllBytes(p))
                    {
                        Format = Path.GetExtension(p),
                        Genre  = music.Tag.Genres
                    };
                    AlbumToSend.Add(MusicUpload);
                }

                IsUploadValid = true;

                Close();
            }
        }
        public void ManageLeases(object state)
        {
            object syncRoot = this._objects.SyncRoot;

            lock (syncRoot)
            {
                int i = 0;
                while (i < this._objects.Count)
                {
                    ServerIdentity serverIdentity = (ServerIdentity)this._objects[i];
                    serverIdentity.Lease.UpdateState();
                    if (serverIdentity.Lease.CurrentState == LeaseState.Expired)
                    {
                        this._objects.RemoveAt(i);
                        serverIdentity.OnLifetimeExpired();
                    }
                    else
                    {
                        i++;
                    }
                }
                if (this._objects.Count == 0)
                {
                    this.StopManager();
                }
            }
        }
示例#3
0
        internal void InternalInvokeAsync(IMessageSink ar, Message reqMsg, bool useDispatchMessage, int callType)
        {
            Identity         identityObject  = this.IdentityObject;
            ServerIdentity   serverIdentity  = identityObject as ServerIdentity;
            MethodCall       methodCall      = new MethodCall((IMessage)reqMsg);
            IInternalMessage internalMessage = (IInternalMessage)methodCall;

            internalMessage.IdentityObject = identityObject;
            if (serverIdentity != null)
            {
                internalMessage.ServerIdentityObject = serverIdentity;
            }
            if (useDispatchMessage)
            {
                ChannelServices.AsyncDispatchMessage((IMessage)methodCall, (callType & 8) != 0 ? (IMessageSink)null : ar);
            }
            else
            {
                if (identityObject.EnvoyChain == null)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("Remoting_Proxy_InvalidState"));
                }
                identityObject.EnvoyChain.AsyncProcessMessage((IMessage)methodCall, (callType & 8) != 0 ? (IMessageSink)null : ar);
            }
            if ((callType & 1) == 0 || (callType & 8) == 0)
            {
                return;
            }
            ar.SyncProcessMessage((IMessage)null);
        }
示例#4
0
        internal void InternalInvokeAsync(IMessageSink ar, Message reqMsg, bool useDispatchMessage, int callType)
        {
            Identity         identityObject = this.IdentityObject;
            ServerIdentity   identity2      = identityObject as ServerIdentity;
            MethodCall       msg            = new MethodCall(reqMsg);
            IInternalMessage message        = msg;

            message.IdentityObject = identityObject;
            if (identity2 != null)
            {
                message.ServerIdentityObject = identity2;
            }
            if (useDispatchMessage)
            {
                ChannelServices.AsyncDispatchMessage(msg, ((callType & 8) != 0) ? null : ar);
            }
            else
            {
                if (identityObject.EnvoyChain == null)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("Remoting_Proxy_InvalidState"));
                }
                identityObject.EnvoyChain.AsyncProcessMessage(msg, ((callType & 8) != 0) ? null : ar);
            }
            if (((callType & 1) != 0) && ((callType & 8) != 0))
            {
                ar.SyncProcessMessage(null);
            }
        }
 public RouterServerInfoProviderConfig(int serverInfoListUpdateIntervalMs,
                                       int serverUnregisterTimeoutMs, ServerIdentity identity)
 {
     ServerInfoListUpdateIntervalMs = serverInfoListUpdateIntervalMs;
     ServerUnregisterTimeoutMs      = serverUnregisterTimeoutMs;
     Identity = identity;
 }
        public IMessage SyncProcessMessage(IMessage msg)
        {
            ServerIdentity serverIdentity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);
            Context        context        = null;

            if (Thread.CurrentContext != serverIdentity.Context)
            {
                context = Context.SwitchToContext(serverIdentity.Context);
            }
            IMessage result;

            try
            {
                Context.NotifyGlobalDynamicSinks(true, msg, false, false);
                Thread.CurrentContext.NotifyDynamicSinks(true, msg, false, false);
                result = serverIdentity.Context.GetServerContextSinkChain().SyncProcessMessage(msg);
                Context.NotifyGlobalDynamicSinks(false, msg, false, false);
                Thread.CurrentContext.NotifyDynamicSinks(false, msg, false, false);
            }
            catch (Exception e)
            {
                result = new ReturnMessage(e, (IMethodCallMessage)msg);
            }
            finally
            {
                if (context != null)
                {
                    Context.SwitchToContext(context);
                }
            }
            return(result);
        }
 public void AddServer(ServerIdentity si)
 {
     ServerList.Add(si);
     UIServerSelector.Items.Add(si.IPEndPoint.ToString());
     UIServerSelector.SelectedIndex = UIServerSelector.Items.Count - 1;
     RequestFavorite();
 }
示例#8
0
        internal static ServerIdentity CheckDisconnectedOrCreateWellKnownObject(IMessage msg)
        {
            ServerIdentity serverIdentity = InternalSink.GetServerIdentity(msg);

            if (serverIdentity == null || serverIdentity.IsRemoteDisconnected())
            {
                string uri = InternalSink.GetURI(msg);
                if (uri != null)
                {
                    ServerIdentity serverIdentity2 = RemotingConfigHandler.CreateWellKnownObject(uri);
                    if (serverIdentity2 != null)
                    {
                        serverIdentity = serverIdentity2;
                    }
                }
            }
            if (serverIdentity == null || serverIdentity.IsRemoteDisconnected())
            {
                string uri2 = InternalSink.GetURI(msg);
                throw new RemotingException(Environment.GetResourceString("Remoting_Disconnected", new object[]
                {
                    uri2
                }));
            }
            return(serverIdentity);
        }
        public virtual IMessage SyncProcessMessage(IMessage reqMsg)
        {
            object[] args = new object[2];
            IMessage message1;

            try
            {
                IMessage message2 = InternalSink.ValidateMessage(reqMsg);
                if (message2 != null)
                {
                    return(message2);
                }
                ServerIdentity serverIdentity = InternalSink.GetServerIdentity(reqMsg);
                args[0]  = (object)reqMsg;
                args[1]  = (object)serverIdentity.ServerContext;
                message1 = (IMessage)Thread.CurrentThread.InternalCrossContextCallback(serverIdentity.ServerContext, CrossContextChannel.s_xctxDel, args);
            }
            catch (Exception ex)
            {
                IMethodCallMessage mcm = (IMethodCallMessage)reqMsg;
                message1 = (IMessage) new ReturnMessage(ex, mcm);
                if (reqMsg != null)
                {
                    ((ReturnMessage)message1).SetLogicalCallContext((LogicalCallContext)reqMsg.Properties[(object)Message.CallContextKey]);
                }
            }
            return(message1);
        }
示例#10
0
        internal static ServerIdentity GetServerIdentity(IMessage reqMsg)
        {
            ServerIdentity   serverIdentityObject = null;
            bool             flag    = false;
            IInternalMessage message = reqMsg as IInternalMessage;

            if (message != null)
            {
                serverIdentityObject = ((IInternalMessage)reqMsg).ServerIdentityObject;
                flag = true;
            }
            else if (reqMsg is InternalMessageWrapper)
            {
                serverIdentityObject = (ServerIdentity)((InternalMessageWrapper)reqMsg).GetServerIdentityObject();
            }
            if (serverIdentityObject == null)
            {
                Identity identity2 = IdentityHolder.ResolveIdentity(GetURI(reqMsg));
                if (identity2 is ServerIdentity)
                {
                    serverIdentityObject = (ServerIdentity)identity2;
                    if (flag)
                    {
                        message.ServerIdentityObject = serverIdentityObject;
                    }
                }
            }
            return(serverIdentityObject);
        }
示例#11
0
        public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
        {
                        #if !DISABLE_REMOTING
            ServerIdentity identity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg);
            if (identity.HasServerDynamicSinks)
            {
                identity.NotifyServerDynamicSinks(true, msg, false, true);
                if (replySink != null)
                {
                    replySink = new ServerObjectReplySink(identity, replySink);
                }
            }

            IMessageCtrl res = _nextSink.AsyncProcessMessage(msg, replySink);

            if (replySink == null)
            {
                identity.NotifyServerDynamicSinks(false, msg, true, true);
            }

            return(res);
                        #else
            IMessageCtrl res = _nextSink.AsyncProcessMessage(msg, replySink);
            return(res);
                        #endif
        }
        internal static void StartListeningForRemoteRequests()
        {
            ActivationServices.Startup();
            DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData;

            if (!remotingData.ActivatorListening)
            {
                object configLock = remotingData.ConfigLock;
                bool   flag       = false;
                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                    Monitor.Enter(configLock, ref flag);
                    if (!remotingData.ActivatorListening)
                    {
                        RemotingServices.MarshalInternal(Thread.GetDomain().RemotingData.ActivationListener, "RemoteActivationService.rem", typeof(IActivator));
                        ServerIdentity serverIdentity = (ServerIdentity)IdentityHolder.ResolveIdentity("RemoteActivationService.rem");
                        serverIdentity.SetSingletonObjectMode();
                        remotingData.ActivatorListening = true;
                    }
                }
                finally
                {
                    if (flag)
                    {
                        Monitor.Exit(configLock);
                    }
                }
            }
        }
 internal MethodCall(object handlerObject, BinaryMethodCallMessage smuggledMsg)
 {
     if (handlerObject != null)
     {
         this.uri = handlerObject as string;
         if (this.uri == null)
         {
             MarshalByRefObject obj2 = handlerObject as MarshalByRefObject;
             if (obj2 != null)
             {
                 bool flag;
                 this.srvID = MarshalByRefObject.GetIdentity(obj2, out flag) as ServerIdentity;
                 this.uri   = this.srvID.URI;
             }
         }
     }
     this.typeName        = smuggledMsg.TypeName;
     this.methodName      = smuggledMsg.MethodName;
     this.methodSignature = (Type[])smuggledMsg.MethodSignature;
     this.args            = smuggledMsg.Args;
     this.instArgs        = smuggledMsg.InstantiationArgs;
     this.callContext     = smuggledMsg.LogicalCallContext;
     this.ResolveMethod();
     if (smuggledMsg.HasProperties)
     {
         smuggledMsg.PopulateMessageProperties(this.Properties);
     }
 }
示例#14
0
        public override IMessage Invoke(IMessage reqMsg)
        {
            IConstructionCallMessage constructionCallMessage = reqMsg as IConstructionCallMessage;

            if (constructionCallMessage != null)
            {
                return(this.InternalActivate(constructionCallMessage));
            }
            if (!base.Initialized)
            {
                if (this.CtorThread != Thread.CurrentThread.GetHashCode())
                {
                    throw new RemotingException(Environment.GetResourceString("Remoting_Proxy_InvalidCall"));
                }
                ServerIdentity serverIdentity = this.IdentityObject as ServerIdentity;
                RemotingServices.Wrap((ContextBoundObject)base.UnwrappedServerObject);
            }
            int     callType = 0;
            Message message  = reqMsg as Message;

            if (message != null)
            {
                callType = message.GetCallType();
            }
            return(this.InternalInvoke((IMethodCallMessage)reqMsg, false, callType));
        }
 public Task <List <int> > GetServerId(ServerIdentity identity)
 {
     return(Task.FromResult <List <int> >(_serverInfos
                                          .Where(s => s.Address == identity.Address && s.Ports == identity.PortsString)
                                          .Select(s => s.Id)
                                          .ToList()));
 }
示例#16
0
 public void StopTrackingLifetime(ServerIdentity identity)
 {
     lock (_objects.SyncRoot)
     {
         _objects.Remove(identity);
     }
 }
示例#17
0
        public virtual IMessage SyncProcessMessage(IMessage reqMsg)
        {
            IMessage message = InternalSink.ValidateMessage(reqMsg);

            if (message != null)
            {
                return(message);
            }
            ServerIdentity serverIdentity         = InternalSink.GetServerIdentity(reqMsg);
            ArrayWithSize  serverSideDynamicSinks = serverIdentity.ServerSideDynamicSinks;

            if (serverSideDynamicSinks != null)
            {
                DynamicPropertyHolder.NotifyDynamicSinks(reqMsg, serverSideDynamicSinks, false, true, false);
            }
            IMessageSink messageSink = this._stackBuilderSink.ServerObject as IMessageSink;
            IMessage     message2;

            if (messageSink != null)
            {
                message2 = messageSink.SyncProcessMessage(reqMsg);
            }
            else
            {
                message2 = this._stackBuilderSink.SyncProcessMessage(reqMsg);
            }
            if (serverSideDynamicSinks != null)
            {
                DynamicPropertyHolder.NotifyDynamicSinks(message2, serverSideDynamicSinks, false, false, false);
            }
            return(message2);
        }
示例#18
0
        public void TestKeyExchange(ScpConfig.EncryptionMode encryptionMode)
        {
            // Client side
            var clientEph       = ECDHHelper.CreateCngKey();
            var clientEphCng    = ECDHHelper.CreateECDiffieHellmanCngSha256(clientEph);
            var clientEphPubKey = clientEphCng.PublicKey();

            // Server side
            var secretarium = new MockedSecretarium(encryptionMode);

            Assert.IsTrue(secretarium.GetServerHello(clientEphPubKey, out byte[] serverHello));
            Assert.IsTrue(ServerHello.Parse(serverHello, 18, out ServerHello serverHelloObj));

            // Client side
            Assert.IsTrue(DiffieHellmanHelper.ComputeProofOfWork(serverHelloObj.proofOfWorkDetails, out byte[] proofOfWork));
            var clientProofOfWork = ByteHelper.Combine(proofOfWork.ExtendTo(32), MockedSecretarium.GenesisPubKey);

            // Server side
            Assert.IsTrue(secretarium.GetServerIdentity(clientProofOfWork, out byte[] serverIdentity));
            Assert.IsTrue(ServerIdentity.Parse(serverIdentity, out ServerIdentity serverIdentityObj));

            // Client side
            var symmetricKey = DiffieHellmanHelper.GetSymmetricKey(
                clientEphCng, serverIdentityObj.ephDHKey, serverIdentityObj.preMasterSecret);

            // Check keys are the same both sides
            Assert.IsTrue(symmetricKey.SequenceEqual(secretarium.Session.SymmetricKey));
        }
示例#19
0
        internal static object ActivateWithMessage(Type serverType, IMessage msg, ServerIdentity srvIdToBind, out Exception e)
        {
            e = (Exception)null;
            object obj = (object)RemotingServices.AllocateUninitializedObject(serverType);
            object server;

            if (serverType.IsContextful)
            {
                object proxy = !(msg is ConstructorCallMessage) ? (object)null : ((ConstructorCallMessage)msg).GetThisPtr();
                server = RemotingServices.Wrap((ContextBoundObject)obj, proxy, false);
            }
            else
            {
                if (Thread.CurrentContext != Context.DefaultContext)
                {
                    throw new RemotingException(Environment.GetResourceString("Remoting_Activation_Failed"));
                }
                server = obj;
            }
            IMethodReturnMessage methodReturnMessage = (IMethodReturnMessage) new StackBuilderSink(server).SyncProcessMessage(msg);

            if (methodReturnMessage.Exception == null)
            {
                if (serverType.IsContextful)
                {
                    return(RemotingServices.Wrap((ContextBoundObject)obj));
                }
                return(obj);
            }
            e = methodReturnMessage.Exception;
            return((object)null);
        }
示例#20
0
        internal static ServerIdentity GetServerIdentity(IMessage reqMsg)
        {
            ServerIdentity   serverIdentity  = null;
            bool             flag            = false;
            IInternalMessage internalMessage = reqMsg as IInternalMessage;

            if (internalMessage != null)
            {
                serverIdentity = ((IInternalMessage)reqMsg).ServerIdentityObject;
                flag           = true;
            }
            else if (reqMsg is InternalMessageWrapper)
            {
                serverIdentity = (ServerIdentity)((InternalMessageWrapper)reqMsg).GetServerIdentityObject();
            }
            if (serverIdentity == null)
            {
                string   uri      = InternalSink.GetURI(reqMsg);
                Identity identity = IdentityHolder.ResolveIdentity(uri);
                if (identity is ServerIdentity)
                {
                    serverIdentity = (ServerIdentity)identity;
                    if (flag)
                    {
                        internalMessage.ServerIdentityObject = serverIdentity;
                    }
                }
            }
            return(serverIdentity);
        }
示例#21
0
        public static void AddServerToXml(ServerIdentity si)
        {
            if (si == null)
            {
                return;
            }
            if (IsExisting(si))
            {
                return;
            }
            XmlDocument doc = new XmlDocument();

            doc.Load(Path);

            XmlNode nodeServer = doc.CreateElement("Server");

            XmlNode nodeIP = doc.CreateElement("Ip");

            nodeIP.InnerText = si.IPEndPoint.Address.ToString();
            nodeServer.AppendChild(nodeIP);

            XmlNode nodePort = doc.CreateElement("Port");

            nodePort.InnerText = si.IPEndPoint.Port.ToString();
            nodeServer.AppendChild(nodePort);

            doc.DocumentElement.AppendChild(nodeServer);

            doc.Save(Path);
        }
示例#22
0
        public IConstructionReturnMessage Activate(IConstructionCallMessage ctorCall)
        {
            ServerIdentity identity = RemotingServices.CreateContextBoundObjectIdentity(ctorCall.ActivationType);

            RemotingServices.SetMessageTargetIdentity(ctorCall, identity);

            ConstructionCall call = ctorCall as ConstructionCall;

            if (call == null || !call.IsContextOk)
            {
                identity.Context = Context.CreateNewContext(ctorCall);
                Context oldContext = Context.SwitchToContext(identity.Context);

                try
                {
                    return(m_NextActivator.Activate(ctorCall));
                }
                finally
                {
                    Context.SwitchToContext(oldContext);
                }
            }
            else
            {
                return(m_NextActivator.Activate(ctorCall));
            }
        }
示例#23
0
        // This is called from InternalInvoke above when someone makes an
        // Async (or a one way) call on a TP
        internal void InternalInvokeAsync(IMessageSink ar, Message reqMsg,
                                          bool useDispatchMessage, int callType)
        {
            IMessageCtrl     cc       = null;
            Identity         idObj    = IdentityObject;
            ServerIdentity   serverID = idObj as ServerIdentity;
            MethodCall       cpyMsg   = new MethodCall(reqMsg);
            IInternalMessage iim      = ((IInternalMessage)cpyMsg);

            // Set the identity in the message object
            iim.IdentityObject = idObj;
            if (null != serverID)
            {
                Message.DebugOut("Setting SrvID on deser msg\n");
                iim.ServerIdentityObject = serverID;
            }

            if (useDispatchMessage)
            {
                Message.DebugOut(
                    "RemotingProxy.Invoke: Calling AsyncDispatchMessage\n");

                BCLDebug.Assert(ar != null, "ar != null");
                BCLDebug.Assert((callType & Message.BeginAsync) != 0,
                                "BeginAsync flag not set!");

                Message.DebugOut("Calling AsynDispatchMessage \n");
                cc = ChannelServices.AsyncDispatchMessage(
                    cpyMsg,
                    ((callType & Message.OneWay) != 0)
                                        ? null : ar);
            }
            else if (null != idObj.EnvoyChain)
            {
                Message.DebugOut("RemotingProxy.Invoke: Calling AsyncProcessMsg on the envoy chain\n");

                cc = idObj.EnvoyChain.AsyncProcessMessage(
                    cpyMsg,
                    ((callType & Message.OneWay) != 0)
                                        ? null : ar);
            }
            else
            {
                // Channel sink cannot be null since it is the last sink in
                // the client context
                // Assert if Invoke is called without a channel sink
                BCLDebug.Assert(false, "How did we get here?");

                throw new InvalidOperationException(
                          Environment.GetResourceString("Remoting_Proxy_InvalidState"));
            }

            if ((callType & Message.BeginAsync) != 0)
            {
                if ((callType & Message.OneWay) != 0)
                {
                    ar.SyncProcessMessage(null);
                }
            }
        }
示例#24
0
        } // CreateServerChannelSinkChain

        // Check if the object has been disconnected or if it is
        // a well known object then we have to create it lazily.
        internal static ServerIdentity CheckDisconnectedOrCreateWellKnownObject(IMessage msg)
        {
            ServerIdentity ident = InternalSink.GetServerIdentity(msg);

            BCLDebug.Trace("REMOTE", "Identity found = " + (ident == null ? "null" : "ServerIdentity"));

            // If the identity is null, then we should check whether the
            // request if for a well known object. If yes, then we should
            // create the well known object lazily and marshal it.
            if ((ident == null) || ident.IsRemoteDisconnected())
            {
                String uri = InternalSink.GetURI(msg);
                BCLDebug.Trace("REMOTE", "URI " + uri);
                if (uri != null)
                {
                    ServerIdentity newIdent = RemotingConfigHandler.CreateWellKnownObject(uri);
                    if (newIdent != null)
                    {
                        // The uri was a registered wellknown object.
                        ident = newIdent;
                        BCLDebug.Trace("REMOTE", "Identity created = " + (ident == null ? "null" : "ServerIdentity"));
                    }
                }
            }


            if ((ident == null) || (ident.IsRemoteDisconnected()))
            {
                String uri = InternalSink.GetURI(msg);
                throw new RemotingException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Disconnected"), uri));
            }
            return(ident);
        }
示例#25
0
        public void ManageLeases(object state)
        {
            lock (_objects.SyncRoot)
            {
                int n = 0;
                while (n < _objects.Count)
                {
                    ServerIdentity ident = (ServerIdentity)_objects[n];
                    ident.Lease.UpdateState();
                    if (ident.Lease.CurrentState == LeaseState.Expired)
                    {
                        _objects.RemoveAt(n);
                        ident.OnLifetimeExpired();
                    }
                    else
                    {
                        n++;
                    }
                }

                if (_objects.Count == 0)
                {
                    StopManager();
                }
            }
        }
示例#26
0
        internal static IMessageCtrl DoAsyncDispatch(IMessage reqMsg, IMessageSink replySink)
        {
            object[]       args           = new object[4];
            ServerIdentity serverIdentity = InternalSink.GetServerIdentity(reqMsg);

            if (RemotingServices.CORProfilerTrackRemotingAsync())
            {
                Guid id = Guid.Empty;
                if (RemotingServices.CORProfilerTrackRemotingCookie())
                {
                    object obj = reqMsg.Properties[(object)"CORProfilerCookie"];
                    if (obj != null)
                    {
                        id = (Guid)obj;
                    }
                }
                RemotingServices.CORProfilerRemotingServerReceivingMessage(id, true);
                if (replySink != null)
                {
                    replySink = (IMessageSink) new ServerAsyncReplyTerminatorSink(replySink);
                }
            }
            Context serverContext = serverIdentity.ServerContext;

            args[0] = (object)reqMsg;
            args[1] = (object)replySink;
            args[2] = (object)Thread.CurrentContext;
            args[3] = (object)serverContext;
            InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(CrossContextChannel.DoAsyncDispatchCallback);

            return((IMessageCtrl)Thread.CurrentThread.InternalCrossContextCallback(serverContext, ftnToCall, args));
        }
        protected static object FixupArg(object arg, ref ArrayList argsToSerialize)
        {
            int count;

            if (arg == null)
            {
                return(null);
            }
            MarshalByRefObject proxy = arg as MarshalByRefObject;

            if (proxy != null)
            {
                if (!RemotingServices.IsTransparentProxy(proxy) || (RemotingServices.GetRealProxy(proxy) is RemotingProxy))
                {
                    ObjRef ref2 = RemotingServices.MarshalInternal(proxy, null, null);
                    if (ref2.CanSmuggle())
                    {
                        if (!RemotingServices.IsTransparentProxy(proxy))
                        {
                            ServerIdentity identity = (ServerIdentity)MarshalByRefObject.GetIdentity(proxy);
                            identity.SetHandle();
                            ref2.SetServerIdentity(identity.GetHandle());
                            ref2.SetDomainID(AppDomain.CurrentDomain.GetId());
                        }
                        ObjRef objRef = ref2.CreateSmuggleableCopy();
                        objRef.SetMarshaledObject();
                        return(new SmuggledObjRef(objRef));
                    }
                }
                if (argsToSerialize == null)
                {
                    argsToSerialize = new ArrayList();
                }
                count = argsToSerialize.Count;
                argsToSerialize.Add(arg);
                return(new SerializedArg(count));
            }
            if (CanSmuggleObjectDirectly(arg))
            {
                return(arg);
            }
            Array array = arg as Array;

            if (array != null)
            {
                Type elementType = array.GetType().GetElementType();
                if (elementType.IsPrimitive || (elementType == typeof(string)))
                {
                    return(array.Clone());
                }
            }
            if (argsToSerialize == null)
            {
                argsToSerialize = new ArrayList();
            }
            count = argsToSerialize.Count;
            argsToSerialize.Add(arg);
            return(new SerializedArg(count));
        }
示例#28
0
 public void ModifyUser(User user, ServerIdentity serverIdentity)
 {
     Invoke((MethodInvoker) delegate
     {
         ServersUsers[serverIdentity] = user;
         UpdateAccountDetails();
     });
 }
 internal AsyncWorkItem(IMessage reqMsg, IMessageSink replySink, Context oldCtx, ServerIdentity srvID)
 {
     this._reqMsg    = reqMsg;
     this._replySink = replySink;
     this._oldCtx    = oldCtx;
     this._callCtx   = CallContext.GetLogicalCallContext();
     this._srvID     = srvID;
 }
示例#30
0
 [System.Security.SecurityCritical]  // auto-generated
 internal AsyncWorkItem(IMessage reqMsg, IMessageSink replySink, Context oldCtx, ServerIdentity srvID)
 {
     _reqMsg    = reqMsg;
     _replySink = replySink;
     _oldCtx    = oldCtx;
     _callCtx   = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext;
     _srvID     = srvID;
 }
示例#31
0
        [System.Security.SecurityCritical]  // auto-generated 
        internal MethodCall(Object handlerObject, BinaryMethodCallMessage smuggledMsg)
        {
            if (handlerObject != null)
            { 
                uri = handlerObject as String;
                if (uri == null) 
                { 
                    // This must be the tranparent proxy
                    MarshalByRefObject mbr = handlerObject as MarshalByRefObject; 
                    if (mbr != null)
                    {
                        bool fServer;
                        srvID = MarshalByRefObject.GetIdentity(mbr, out fServer) as ServerIdentity; 
                        uri = srvID.URI;
                    } 
                } 
            }
 
            typeName = smuggledMsg.TypeName;
            methodName = smuggledMsg.MethodName;
            methodSignature = (Type[])smuggledMsg.MethodSignature;
            args = smuggledMsg.Args; 
            instArgs = smuggledMsg.InstantiationArgs;
            callContext = smuggledMsg.LogicalCallContext; 
 
            ResolveMethod();
 
            if (smuggledMsg.HasProperties)
                smuggledMsg.PopulateMessageProperties(Properties);
        }
示例#32
0
        [System.Security.SecurityCritical]  // auto-generated 
        internal TransitionCall( 
            IntPtr targetCtxID,
            CrossContextDelegate deleg) 
        {
            Contract.Assert(targetCtxID!=IntPtr.Zero, "bad target ctx for call back");
            _sourceCtxID = Thread.CurrentContext.InternalContextID;
            _targetCtxID = targetCtxID; 
            _delegate = deleg;
            _targetDomainID = 0; 
            _eeData = IntPtr.Zero; 

            // We are going to another context in the same app domain 
            _srvID = new ServerIdentity(
                null,
                Thread.GetContextInternal(_targetCtxID));
            _ID = _srvID; 
            _ID.RaceSetChannelSink(CrossContextChannel.MessageSink);
            _srvID.RaceSetServerObjectChain(this); 
 
            //DBG Console.WriteLine("### TransitionCall ctor: " + Int32.Format(_sourceCtxID,"x") + ":" + Int32.Format(_targetCtxID,"x"));
        } // TransitionCall 
示例#33
0
        [System.Security.SecurityCritical]  // auto-generated 
        internal TransitionCall(IntPtr targetCtxID, IntPtr eeData, int targetDomainID)
            { 
            Contract.Assert(targetCtxID != IntPtr.Zero, "bad target ctx for call back"); 
            Contract.Assert(targetDomainID !=0, "bad target ctx for call back");
 
            _sourceCtxID = Thread.CurrentContext.InternalContextID;
            _targetCtxID = targetCtxID;
            _delegate = null;
            _targetDomainID = targetDomainID; 
            _eeData = eeData;
 
 
            // In the cross domain case, the client side just has a base Identity
            // and the server domain has the Server identity. We fault in the latter 
            // when requested later.

            // We are going to a context in another app domain
            _srvID = null; 
            _ID = new Identity("TransitionCallURI", null);
 
                // Create the data needed for the channel sink creation 
            CrossAppDomainData data =
                new CrossAppDomainData(_targetCtxID, 
                    _targetDomainID,
                    Identity.ProcessGuid);
            String unUsed;
            IMessageSink channelSink = 
            CrossAppDomainChannel.AppDomainChannel.CreateMessageSink(
                null, //uri 
                data, //channelData 
                out unUsed);//out objURI
 
            Contract.Assert(channelSink != null, "X-domain transition failure");
            _ID.RaceSetChannelSink(channelSink);
        } // TransitionCall
示例#34
0
		internal static void TrackLifetime (ServerIdentity identity)
		{
			_leaseManager.TrackLifetime (identity);
		}
示例#35
0
		internal static void StopTrackingLifetime (ServerIdentity identity)
		{
			_leaseManager.StopTrackingLifetime (identity);
		}
		public ServerObjectReplySink (ServerIdentity identity, IMessageSink replySink)
		{
			_replySink = replySink;
			_identity = identity;
		}
示例#37
0
        } // ResolveTypeRelativeTo 
#endif // FEATURE_REMOTING 

        internal Type ResolveType() 
        {
            // resolve type
            Type t = null;
 
            if (srvID == null)
                srvID = IdentityHolder.CasualResolveIdentity(uri) as ServerIdentity; 
 
            if (srvID != null)
            { 
                Type serverType = srvID.GetLastCalledType(typeName);
                if (serverType != null)
                        return serverType;
                int startIndex = 0; // start of type name 

                // check to see if type name starts with "clr:" 
                if (String.CompareOrdinal(typeName, 0, "clr:", 0, 4) == 0) 
                {
                    // type starts just past "clr:" 
                    startIndex = 4;
                }

                // find end of full type name 
                int index = typeName.IndexOf(',', startIndex);
                if (index == -1) 
                    index = typeName.Length; 

                serverType = srvID.ServerType; 
                t = ResolveTypeRelativeTo(typeName, startIndex, index - startIndex, serverType);
            }

            if (t == null) 
            {
                // fall back to Type.GetType() in case someone isn't using 
                //   our convention for the TypeName 
                t = RemotingServices.InternalGetTypeFromQualifiedTypeName(typeName);
            } 
            if (srvID != null)
                srvID.SetLastCalledType(typeName, t);
            return t;
        } // ResolveType