Exemplo n.º 1
0
        public void RegisterAdapter(IAdapter adapter, string channel)
        {
            if (_adapters.ContainsKey(channel))
                throw new ApplicationException("There is already an adapter registered on that channel.");

            var filteredAdapter = new MessageFilterAdapter(adapter, _filters);

            _adapters.Add(channel, filteredAdapter);

            if (filteredAdapter.Producer != null)
            {
                filteredAdapter.Producer.MessageProduced += OnMessageProduced;
            }
        }
Exemplo n.º 2
0
        private Dictionary <string, IAdapter> BuildAdapters(List <IMessageFilter> filters)
        {
            var result = new Dictionary <string, IAdapter>();

            foreach (var channel in _adapterRegistrations.Keys)
            {
                var adapter = _adapterRegistrations[channel](_configuration);

                if (result.ContainsKey(channel))
                {
                    throw new ApplicationException("There is already an adapter registered on that channel.");
                }

                var filteredAdapter = new MessageFilterAdapter(adapter, filters);

                result.Add(channel, filteredAdapter);
            }

            return(result);
        }