Esempio n. 1
0
        public List <ClientId> ResolveAll(Type interfaceType)
        {
            List <ClientId> list      = new List <ClientId>();
            SuperPool       superPool = this._superPool;

            if (superPool != null)
            {
                list.AddRange(superPool.GetInterfaceImplementors(interfaceType));
            }
            return(list);
        }
Esempio n. 2
0
        internal void ReleaseSuperPool()
        {
            lock (this._syncRoot)
                this._superPool = (SuperPool)null;
            SuperPoolClientUpdateDelegate clientUpdateDelegate = this.SuperPoolReleasedEvent;

            if (clientUpdateDelegate == null)
            {
                return;
            }
            clientUpdateDelegate((ISuperPoolClient)this);
        }
Esempio n. 3
0
        public ClientId Resolve(Type interfaceType)
        {
            SuperPool superPool = this._superPool;

            if (superPool != null)
            {
                using (IEnumerator <ClientId> enumerator = superPool.GetInterfaceImplementors(interfaceType).GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        return(enumerator.Current);
                    }
                }
            }
            return((ClientId)null);
        }
Esempio n. 4
0
        protected TType DoCallMany <TType>(IEnumerable <ComponentId> receivers, TimeSpan?timeOut) where TType : class
        {
            SuperPool superPool = this._superPool;

            if (superPool == null)
            {
                return(default(TType));
            }
            TType result;
            SuperPoolProxyCall call;

            if (!superPool.Call <TType>(this, receivers, out result, out call))
            {
                return(default(TType));
            }
            call.Timeout = timeOut;
            return(result);
        }
Esempio n. 5
0
        internal void AssignSuperPool(SuperPool superPool)
        {
            lock (this._syncRoot)
            {
                if (this._superPool != null && this._superPool != superPool)
                {
                    throw new Exception("Client already assigned to another super pool.");
                }
                this._superPool = superPool;
            }
            SuperPoolClientUpdateDelegate clientUpdateDelegate = this.SuperPoolAssignedEvent;

            if (clientUpdateDelegate == null)
            {
                return;
            }
            clientUpdateDelegate((ISuperPoolClient)this);
        }
Esempio n. 6
0
        public TType Subscribe <TType>(EventSubscriptionRequest subscription) where TType : class
        {
            SuperPool superPool = this._superPool;

            if (superPool == null)
            {
                return(default(TType));
            }
            TType resultValue;

            if (superPool.Subscribe <TType>(this, subscription, out resultValue))
            {
                return(resultValue);
            }
            else
            {
                return(default(TType));
            }
        }
Esempio n. 7
0
        protected TType DoCall <TType>(ComponentId receiverId, TimeSpan?requestConfirmTimeout, TimeSpan?timeout, AsyncCallResultDelegate asyncResultDelegate, object asyncResultState, TimeSpan?asyncResultTimeout, SuperPoolProxyCall.ModeEnum callMode, CallOutcome outcome) where TType : class
        {
            SuperPool superPool = this._superPool;

            if (superPool == null)
            {
                return(default(TType));
            }
            TType result;
            SuperPoolProxyCall call;

            if (!superPool.Call <TType>(this, receiverId, out result, out call))
            {
                return(default(TType));
            }
            call.AsyncResultDelegate   = asyncResultDelegate;
            call.AsyncResultState      = asyncResultState;
            call.AsyncResultTimeout    = asyncResultTimeout;
            call.RequestConfirmTimeout = requestConfirmTimeout;
            call.Timeout = timeout;
            call.Mode    = callMode;
            call.Outcome = outcome;
            return(result);
        }
Esempio n. 8
0
        protected override void OnPerformExecution(Envelope envelope)
        {
            object source = this.Source;

            if (source == null || envelope.Message.GetType() != typeof(SuperPoolCall))
            {
                base.OnPerformExecution(envelope);
            }
            else
            {
                try
                {
                    SuperPoolCall call = envelope.Message as SuperPoolCall;
                    object        obj1;
                    if (call.State == SuperPoolCall.StateEnum.Responding)
                    {
                        object       result       = call.Parameters.Length > 0 ? call.Parameters[0] : (object)null;
                        Exception    exception    = call.Parameters.Length > 1 ? call.Parameters[1] as Exception : (Exception)null;
                        long         id           = call.Id;
                        SyncCallInfo syncCallInfo = (SyncCallInfo)null;
                        lock (this._syncCalls)
                        {
                            if (this._syncCalls.TryGetValue(id, out syncCallInfo))
                            {
                                if (!syncCallInfo.IsMultiResponse)
                                {
                                    this._syncCalls.Remove(id);
                                }
                            }
                            else
                            {
                                syncCallInfo = (SyncCallInfo)null;
                            }
                        }
                        if (syncCallInfo != null)
                        {
                            syncCallInfo.AcceptResponse(this, result, exception);
                            if (syncCallInfo.IsMultiResponse && syncCallInfo.IsMultiResponseComplete)
                            {
                                lock (this._syncCalls)
                                    this._syncCalls.Remove(id);
                            }
                        }
                    }
                    else if (call.State == SuperPoolCall.StateEnum.Requesting)
                    {
                        if (this._consumerInterfacesHotSwap.Contains(call.MethodInfoLocal.ReflectedType))
                        {
                            obj1 = (object)null;
                            Exception exception = (Exception)null;
                            object    obj2      = this.PerformCall(call, source, out exception);
                            if (call.RequestResponse)
                            {
                                call.State = SuperPoolCall.StateEnum.Responding;
                                if (exception == null)
                                {
                                    call.Parameters = new object[1]
                                    {
                                        obj2
                                    }
                                }
                                ;
                                else
                                {
                                    call.Parameters = new object[2]
                                    {
                                        obj2,
                                        (object)exception
                                    }
                                };
                                SuperPool superPool = this._superPool;
                                if (superPool == null)
                                {
                                    return;
                                }
                                IMessageBus messageBus = superPool.MessageBus;
                                if (messageBus == null)
                                {
                                    return;
                                }
                                int num = (int)messageBus.Respond(envelope, new Envelope((object)call)
                                {
                                    DuplicationMode = this.EnvelopeDuplicationMode
                                });
                            }
                            else
                            {
                                call.State = SuperPoolCall.StateEnum.Finished;
                            }
                        }
                        else if (call.MethodInfoLocal != null)
                        {
                            ;
                        }
                    }
                    else if (call.State == SuperPoolCall.StateEnum.EventRaise)
                    {
                        Exception exception;
                        obj1       = this.PerformCall(call, source, out exception);
                        call.State = SuperPoolCall.StateEnum.Finished;
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }