예제 #1
0
        public AdaptersHolder(IMessageSessionHolder session, Action <Exception> errorHandler)
        {
            _errorHandler = errorHandler;

            var transaction = session.IsTransactionEnabled;
            var marketData  = session.IsMarketDataEnabled;

            if (marketData)
            {
                MarketDataAdapter = session.CreateMarketDataAdapter();
            }

            if (transaction)
            {
                TransactionAdapter = session.CreateTransactionAdapter();
            }

            var type        = session.GetType();
            var displayName = type.GetDisplayName();

            if (!session.JoinInProcessors)
            {
                if (transaction)
                {
                    ApplyMessageProcessor(displayName, MessageDirections.In, true, false);
                }

                if (marketData)
                {
                    ApplyMessageProcessor(displayName, MessageDirections.In, false, true);
                }
            }
            else
            {
                ApplyMessageProcessor(displayName, MessageDirections.In, transaction, marketData);
            }

            if (!session.JoinOutProcessors)
            {
                if (transaction)
                {
                    ApplyMessageProcessor(displayName, MessageDirections.Out, true, false);
                }

                if (marketData)
                {
                    ApplyMessageProcessor(displayName, MessageDirections.Out, false, true);
                }
            }
            else
            {
                ApplyMessageProcessor(displayName, MessageDirections.Out, transaction, marketData);
            }
        }
        private ConnectorInfo GetInfo(IMessageSessionHolder sessionHolder)
        {
            if (sessionHolder == null)
            {
                throw new ArgumentNullException("sessionHolder");
            }

            var info = ConnectorsInfo.FirstOrDefault(i => i.SessionHolderType.IsInstanceOfType(sessionHolder));

            if (info == null)
            {
                throw new ArgumentException(LocalizedStrings.Str1553Params.Put(sessionHolder.GetType()), "sessionHolder");
            }

            return(info);
        }