예제 #1
0
        public void Add(string name, RouteBase item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (!String.IsNullOrEmpty(name))
            {
                if (_namedMap.ContainsKey(name))
                {
                    throw new ArgumentException(
                              String.Format(
                                  CultureInfo.CurrentUICulture,
                                  SR.GetString(SR.RouteCollection_DuplicateName),
                                  name),
                              "name");
                }
            }

            Add(item);
            if (!String.IsNullOrEmpty(name))
            {
                _namedMap[name] = item;
            }

            // RouteBase doesn't have handler info, so we only log Route.RouteHandler
            var route = item as Route;

            if (route != null && route.RouteHandler != null)
            {
                TelemetryLogger.LogHttpHandler(route.RouteHandler.GetType());
            }
        }
예제 #2
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));
            }
            TelemetryLogger.LogHttpHandler(instance.GetType());
        }