internal Type GetHandlerType(HttpHandlerAction handlerAction)
 {
     Type typeWithAssert = this.GetTypeWithAssert(handlerAction.Type);
     if (!ConfigUtil.IsTypeHandlerOrFactory(typeWithAssert))
     {
         throw new ConfigurationErrorsException(System.Web.SR.GetString("Type_not_factory_or_handler", new object[] { handlerAction.Type }), handlerAction.ElementInformation.Source, handlerAction.ElementInformation.LineNumber);
     }
     return typeWithAssert;
 }
示例#2
0
        internal Type GetHandlerType(HttpHandlerAction handlerAction)
        {
            Type typeWithAssert = this.GetTypeWithAssert(handlerAction.Type);

            if (!ConfigUtil.IsTypeHandlerOrFactory(typeWithAssert))
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Type_not_factory_or_handler", new object[] { handlerAction.Type }), handlerAction.ElementInformation.Source, handlerAction.ElementInformation.LineNumber);
            }
            return(typeWithAssert);
        }
 internal HttpHandlerAction FindMapping(string verb, VirtualPath path)
 {
     this.ValidateHandlers();
     for (int i = 0; i < this.Handlers.Count; i++)
     {
         HttpHandlerAction action = this.Handlers[i];
         if (action.IsMatch(verb, path))
         {
             return(action);
         }
     }
     return(null);
 }
        internal Type GetHandlerType( HttpHandlerAction handlerAction ) {
            // HACKHACK: for now, let uncreatable types through and error later (for .soap factory)
            // This design should change - developers will want to know immediately
            // when they misspell a type

            Type t = GetTypeWithAssert(handlerAction.Type);

            // throw for bad types in deferred case
            if (!ConfigUtil.IsTypeHandlerOrFactory(t))
                throw new ConfigurationErrorsException(SR.GetString(SR.Type_not_factory_or_handler, handlerAction.Type),
                    handlerAction.ElementInformation.Source, handlerAction.ElementInformation.LineNumber);

            return t;

        }
        internal HandlerFactoryCache(HttpHandlerAction 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, GetHandlerType(mapping));
            }
            else if (instance is IHttpHandlerFactory) {
                _factory = (IHttpHandlerFactory)instance;
            }
            else {
                throw new HttpException(SR.GetString(SR.Type_not_factory_or_handler, instance.GetType().FullName));
            }
        }
 internal HandlerFactoryCache(HttpHandlerAction mapping)
 {
     object obj2 = mapping.Create();
     if (obj2 is IHttpHandler)
     {
         this._factory = new HandlerFactoryWrapper((IHttpHandler) obj2, this.GetHandlerType(mapping));
     }
     else
     {
         if (!(obj2 is IHttpHandlerFactory))
         {
             throw new HttpException(System.Web.SR.GetString("Type_not_factory_or_handler", new object[] { obj2.GetType().FullName }));
         }
         this._factory = (IHttpHandlerFactory) obj2;
     }
 }
        internal HttpHandlerAction FindMapping(String verb, VirtualPath path)
        {
            ValidateHandlers();

            for (int i = 0; i < Handlers.Count; i++)
            {
                HttpHandlerAction m = (HttpHandlerAction)Handlers[i];

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

            return(null);
        }
示例#8
0
        internal Type GetHandlerType(HttpHandlerAction handlerAction)
        {
            // HACKHACK: for now, let uncreatable types through and error later (for .soap factory)
            // This design should change - developers will want to know immediately
            // when they misspell a type

            Type t = GetTypeWithAssert(handlerAction.Type);

            // throw for bad types in deferred case
            if (!ConfigUtil.IsTypeHandlerOrFactory(t))
            {
                throw new ConfigurationErrorsException(SR.GetString(SR.Type_not_factory_or_handler, handlerAction.Type),
                                                       handlerAction.ElementInformation.Source, handlerAction.ElementInformation.LineNumber);
            }

            return(t);
        }
示例#9
0
        internal HandlerFactoryCache(HttpHandlerAction mapping)
        {
            object obj2 = mapping.Create();

            if (obj2 is IHttpHandler)
            {
                this._factory = new HandlerFactoryWrapper((IHttpHandler)obj2, this.GetHandlerType(mapping));
            }
            else
            {
                if (!(obj2 is IHttpHandlerFactory))
                {
                    throw new HttpException(System.Web.SR.GetString("Type_not_factory_or_handler", new object[] { obj2.GetType().FullName }));
                }
                this._factory = (IHttpHandlerFactory)obj2;
            }
        }
示例#10
0
        internal HandlerFactoryCache(HttpHandlerAction 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, GetHandlerType(mapping));
            }
            else if (instance is IHttpHandlerFactory)
            {
                _factory = (IHttpHandlerFactory)instance;
            }
            else
            {
                throw new HttpException(SR.GetString(SR.Type_not_factory_or_handler, instance.GetType().FullName));
            }
        }
示例#11
0
        internal object LocateHandler(string verb, string filepath, out bool allowCache)
        {
            int top = Handlers.Count;

            for (int i = 0; i < top; i++)
            {
                HttpHandlerAction handler = (HttpHandlerAction)Handlers [i];

                string[] verbs = handler.Verbs;
                if (verbs == null)
                {
                    if (handler.PathMatches(filepath))
                    {
                        allowCache = handler.Path != "*";
                        return(handler.GetHandlerInstance());
                    }
                    continue;
                }

                for (int j = verbs.Length; j > 0;)
                {
                    j--;
                    if (verbs [j] != verb)
                    {
                        continue;
                    }
                    if (handler.PathMatches(filepath))
                    {
                        allowCache = handler.Path != "*";
                        return(handler.GetHandlerInstance());
                    }
                }
            }

            allowCache = false;
            return(null);
        }
 internal HandlerMappingMemo(HttpHandlerAction mapping, string verb, VirtualPath path)
 {
     this._mapping = mapping;
     this._verb = verb;
     this._path = path;
 }
 public void Add(HttpHandlerAction httpHandlerAction)
 {
 }
 public int IndexOf(HttpHandlerAction action)
 {
   return default(int);
 }
示例#15
0
 public void Remove(HttpHandlerAction action)
 {
 }
 internal HandlerMappingMemo(HttpHandlerAction mapping, string verb, VirtualPath path)
 {
     this._mapping = mapping;
     this._verb    = verb;
     this._path    = path;
 }
 public int IndexOf(HttpHandlerAction action)
 {
     return(BaseIndexOf(action));
 }
		public void Remove (HttpHandlerAction action)
		{
			HttpApplication.ClearHandlerCache ();
			BaseRemove (action.Path + "-" + action.Verb);
		}
示例#19
0
        bool PathMatches(HttpHandlerAction handler, string uri)
        {
            bool result = false;
            string[] handlerPaths = handler.Path.Split (',');
            int slash = uri.LastIndexOf ('/');
            string origUri = uri;
            if (slash != -1)
                uri = uri.Substring (slash);

            SearchPattern sp = null;
            foreach (string handlerPath in handlerPaths) {
                if (handlerPath == "*")
                    continue; // ignore

                string matchExact = null;
                string endsWith = null;

                if (handlerPath.Length > 0) {
                    if (handlerPath [0] == '*' && (handlerPath.IndexOf ('*', 1) == -1))
                        endsWith = handlerPath.Substring (1);

                    if (handlerPath.IndexOf ('*') == -1)
                        if (handlerPath [0] != '/') {
                            string vpath = HttpRuntime.AppDomainAppVirtualPath;

                            if (vpath == "/")
                                vpath = String.Empty;

                            matchExact = String.Concat (vpath, "/", handlerPath);
                        }
                }

                if (matchExact != null) {
                    result = matchExact.Length == origUri.Length && origUri.EndsWith (matchExact, StringComparison.OrdinalIgnoreCase);
                    if (result)
                        break;
                    continue;
                }
                if (endsWith != null) {
                    result = uri.EndsWith (endsWith, StringComparison.OrdinalIgnoreCase);
                    if (result)
                        break;
                    continue;
                }

                string pattern;
                if (handlerPath.Length > 0 && handlerPath [0] == '/')
                    pattern = handlerPath.Substring (1);
                else
                    pattern = handlerPath;

                if (sp == null)
                    sp = new SearchPattern (pattern, true);
                else
                    sp.SetPattern (pattern, true);

                if (sp.IsMatch (origUri)) {
                    result = true;
                    break;
                }
            }

            return result;
        }
 public void Remove(HttpHandlerAction action)
 {
     BaseRemove(action.Key);
 }
 internal HandlerMappingMemo(HttpHandlerAction mapping, String verb, VirtualPath path)
 {
     _mapping = mapping;
     _verb    = verb;
     _path    = path;
 }
 internal HandlerMappingMemo(HttpHandlerAction mapping, String verb, VirtualPath path) {
     _mapping = mapping;
     _verb = verb;
     _path = path;
 }
 public void Remove(HttpHandlerAction action)
 {
 }
 public void Add(HttpHandlerAction httpHandlerAction) {
     BaseAdd(httpHandlerAction, false);
 }
 private IHttpHandlerFactory GetFactory(HttpHandlerAction mapping)
 {
     HandlerFactoryCache cache = (HandlerFactoryCache) this._handlerFactories[mapping.Type];
     if (cache == null)
     {
         cache = new HandlerFactoryCache(mapping);
         this._handlerFactories[mapping.Type] = cache;
     }
     return cache.Factory;
 }
 public void Add(HttpHandlerAction httpHandlerAction)
 {
     BaseAdd(httpHandlerAction, false);
 }
        internal static void CheckConfiguration(ISite site)
        {
            if (site == null)
            {
                return;
            }

            IWebApplication app = (IWebApplication)site.GetService(typeof(IWebApplication));

            if (app == null)
            {
                return;
            }

            Configuration config = app.OpenWebConfiguration(false);

            HttpHandlersSection handlers = (HttpHandlersSection)config.GetSection("system.web/httpHandlers");

            // Does the httpHandlers Secton already exist?
            if (handlers == null)
            {
                // If not, add it...
                handlers = new HttpHandlersSection();

                ConfigurationSectionGroup group = config.GetSectionGroup("system.web");

                // Does the system.web Section already exist?
                if (group == null)
                {
                    // If not, add it...
                    config.SectionGroups.Add("system.web", new ConfigurationSectionGroup());
                    group = config.GetSectionGroup("system.web");
                }

                if (group != null)
                {
                    group.Sections.Add("httpHandlers", handlers);
                }
            }

            HttpHandlerAction action = new HttpHandlerAction("*/ext.axd", "Ext.Net.ResourceHandler", "*", false);

            // Does the ResourceHandler already exist?
            if (handlers.Handlers.IndexOf(action) < 0)
            {
                // If not, add it...
                handlers.Handlers.Add(action);
                config.Save();
            }



            HttpModulesSection modules = (HttpModulesSection)config.GetSection("system.web/httpModules");

            // Does the httpModules Secton already exist?
            if (modules == null)
            {
                // If not, add it...
                modules = new HttpModulesSection();

                ConfigurationSectionGroup group = config.GetSectionGroup("system.web");

                // Does the system.web Section already exist?
                if (group == null)
                {
                    // If not, add it...
                    config.SectionGroups.Add("system.web", new ConfigurationSectionGroup());
                    group = config.GetSectionGroup("system.web");
                }

                if (group != null)
                {
                    group.Sections.Add("httpModules", modules);
                }
            }


            //<add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" />

            HttpModuleAction action2 = new HttpModuleAction("DirectRequestModule", "Ext.Net.DirectRequestModule, Ext.Net");

            // Does the ResourceHandler already exist?
            if (modules.Modules.IndexOf(action2) < 0)
            {
                // If not, add it...
                modules.Modules.Add(action2);
                config.Save();
            }
        }
        //
        // Request mappings management functions
        //

        private IHttpHandlerFactory GetFactory(HttpHandlerAction mapping) {
            HandlerFactoryCache entry = (HandlerFactoryCache)_handlerFactories[mapping.Type];
            if (entry == null) {
                entry = new HandlerFactoryCache(mapping);
                _handlerFactories[mapping.Type] = entry;
            }

            return entry.Factory;
        }
 public void Add(HttpHandlerAction httpHandlerAction)
 {
     HttpApplication.ClearHandlerCache();
     BaseAdd(httpHandlerAction);
 }
		public void Add (HttpHandlerAction httpHandlerAction)
		{
			HttpApplication.ClearHandlerCache ();
			BaseAdd (httpHandlerAction);
		}
 public void Remove(HttpHandlerAction action)
 {
     HttpApplication.ClearHandlerCache();
     BaseRemove(action.Path + "-" + action.Verb);
 }
 public int IndexOf(HttpHandlerAction action) {
     return BaseIndexOf(action);
 }
示例#33
0
 public void Add(HttpHandlerAction httpHandlerAction)
 {
 }
 public void Remove(HttpHandlerAction action) {
     BaseRemove(action.Key);
 }
示例#35
0
 public int IndexOf(HttpHandlerAction action)
 {
     return(default(int));
 }