Ejemplo n.º 1
0
        internal /*public*/ void Add(HandlerMapping mapping, int phase)
        {
            if (_group[phase] == null)
            {
                _group[phase] = new ArrayList();
            }

            _group[phase].Add(mapping);
        }
Ejemplo n.º 2
0
        internal HandlerFactoryCache(HandlerMapping mapping)
        {
            Object instance = mapping.Create();

            // make sure it is either handler or handler factory

            if (instance is IHttpHandler)
            {
                // create bogus factory around it
                _factory = new HandlerFactoryWrapper((IHttpHandler)instance, mapping.Type);
            }
            else if (instance is IHttpHandlerFactory)
            {
                _factory = (IHttpHandlerFactory)instance;
            }
            else
            {
                throw new HttpException(HttpRuntime.FormatResourceString(SR.Type_not_factory_or_handler, instance.GetType().FullName));
            }
        }
Ejemplo n.º 3
0
        internal /*public*/ bool RemoveMapping(String requestType, String path)
        {
            bool found = false;

            for (int phase = 0; phase < 4; phase++)
            {
                ArrayList list;

                if (phase < 2)
                {
                    list = _phase[phase];
                }
                else
                {
                    list = _group[phase - 2];
                }

                if (list != null)
                {
                    int n = list.Count;

                    for (int i = 0; i < n; i++)
                    {
                        HandlerMapping m = (HandlerMapping)list[i];

                        if (m.IsPattern(requestType, path))
                        {
                            // inefficient if there are many matches

                            list.RemoveAt(i);
                            i--;
                            n--;
                            found = true;
                        }
                    }
                }
            }

            return(found);
        }
Ejemplo n.º 4
0
        internal /*public*/ HandlerMapping FindMapping(String requestType, String path)
        {
            for (int phase = 0; phase < 2; phase++)
            {
                ArrayList list = _phase[phase];

                if (list != null)
                {
                    int n = list.Count;

                    for (int i = 0; i < n; i++)
                    {
                        HandlerMapping m = (HandlerMapping)list[i];

                        if (m.IsMatch(requestType, path))
                        {
                            return(m);
                        }
                    }
                }
            }

            return(null);
        }
 internal HandlerMappingMemo(HandlerMapping mapping, String verb)
 {
     _mapping = mapping;
     _verb    = verb;
 }