Exemplo n.º 1
0
        private void registerOrFilter(IChainFilter filter)
        {
            IChainFilter last = _wheres.LastOrDefault();

            if (last == null)
            {
                _wheres.Add(filter);
            }
            else
            {
                if (last is OrChainFilter)
                {
                    last.As <OrChainFilter>().Add(filter);
                }
                else
                {
                    _wheres.Remove(last);
                    var orFilter = new OrChainFilter();
                    orFilter.Add(last);
                    orFilter.Add(filter);

                    _wheres.Add(orFilter);
                }
            }
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            theFilter = new OrChainFilter();

            filter1 = MockRepository.GenerateMock <IChainFilter>();
            filter2 = MockRepository.GenerateMock <IChainFilter>();
            filter3 = MockRepository.GenerateMock <IChainFilter>();
            filter4 = MockRepository.GenerateMock <IChainFilter>();

            theFilter.Add(filter1);
            theFilter.Add(filter2);
            theFilter.Add(filter3);
            theFilter.Add(filter4);

            aChain = new BehaviorChain();
        }
Exemplo n.º 3
0
            /// <summary>
            /// Filter based on whether or not a chain responds to any of these Http methods
            /// </summary>
            /// <param name="methods">GET, POST, PUT, DELETE, etc.</param>
            /// <returns></returns>
            public IOrExpression RespondsToHttpMethod(params string[] methods)
            {
                if (methods.Count() == 0)
                {
                    throw new ArgumentOutOfRangeException("You need to specify at least one http method");
                }

                if (methods.Count() > 1)
                {
                    var filter = new OrChainFilter();
                    methods.Each(method => filter.Add(new HttpMethodFilter(method)));

                    return(addFilter(filter));
                }

                return(addFilter(new HttpMethodFilter(methods.Single())));
            }