Пример #1
0
        private static SubjectProxy <TMessage> Subject <TMessage>(object sender)
        {
            SubjectProxy <TMessage> msgHandler = null;
            Type type = typeof(TMessage);

            if (!handlers.ContainsKey(type))
            {
                try
                {
                    msgHandler = new SubjectProxy <TMessage>(MessageManager.Subject <TMessage>(sender), IsNeedAsyncRegister);
                    lock (InnerLocker)
                        handlers[type] = msgHandler;
                }
                catch (SocketException ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message);
                }
            }
            else
            {
                msgHandler = handlers[type] as SubjectProxy <TMessage>;
            }

            return(msgHandler);
        }