Exemple #1
0
        static void Match <TInput>(TInput message, MatchHeaderCallback callback)
        {
            if (_matchHeader == null)
            {
                _matchHeader = new MatchHeaderImpl();
            }

            _matchHeader.Match(message, callback);
        }
Exemple #2
0
        public void Match <TInput>(TInput input, MatchHeaderCallback callback)
        {
            if (_directTypes.Contains(typeof(TInput)))
            {
                callback.Body(input);
                return;
            }

            Action <object, MatchHeaderCallback> adapter;

            if (!_adapters.TryGetValue(typeof(TInput), out adapter))
            {
                foreach (MatchHeaderSelectorFactory factory in GetTypeConverters(typeof(TInput)))
                {
                    if (factory.CanMatch(input, out adapter))
                    {
                        break;
                    }
                }

                if (adapter == null)
                {
                    _directTypes.Add(typeof(TInput));
                }
                else
                {
                    _adapters.Add(typeof(TInput), adapter);
                }
            }

            if (adapter == null)
            {
                callback.Body(input);
            }
            else
            {
                adapter(input, callback);
            }
        }
        public MatchHeaderChannel(MatchHeaderCallback callback)
        {
            _callback = callback;

            _match = new MatchHeaderImpl();
        }