コード例 #1
0
 private IHttpHandler GetHandlerSubSequent(HttpContext context, string requestType, string url, string pathTranslated)
 {
     if (this.cachedResult is IHttpHandler)
     {
         return((IHttpHandler)this.cachedResult);
     }
     if (this.cachedResult is IHttpHandlerFactory)
     {
         IHttpHandlerFactory cachedResult = (IHttpHandlerFactory)this.cachedResult;
         return(XamlHttpHandlerFactory.HandlerWrapper.Create(cachedResult.GetHandler(context, requestType, url, pathTranslated), cachedResult));
     }
     if (!(this.cachedResult is Type))
     {
         throw FxTrace.Exception.AsError((ConfigurationErrorsException)this.cachedResult);
     }
     return((IHttpHandler)XamlHttpHandlerFactory.CreateInstance((Type)this.cachedResult));
 }
コード例 #2
0
            private IHttpHandler GetHandlerFirstTime(HttpContext context, string requestType, string url, string pathTranslated)
            {
                Type type;
                ConfigurationErrorsException exception;

                if (this.hostedXamlType == null)
                {
                    this.hostedXamlType = this.GetCompiledCustomString(context.Request.AppRelativeCurrentExecutionFilePath);
                }
                if (XamlHostingConfiguration.TryGetHttpHandlerType(url, this.hostedXamlType, out type))
                {
                    if (TD.HttpHandlerPickedForUrlIsEnabled())
                    {
                        TD.HttpHandlerPickedForUrl(url, this.hostedXamlType.FullName, type.FullName);
                    }
                    if (typeof(IHttpHandler).IsAssignableFrom(type))
                    {
                        IHttpHandler handler = (IHttpHandler)XamlHttpHandlerFactory.CreateInstance(type);
                        if (handler.IsReusable)
                        {
                            this.cachedResult = handler;
                            return(handler);
                        }
                        this.cachedResult = type;
                        return(handler);
                    }
                    if (typeof(IHttpHandlerFactory).IsAssignableFrom(type))
                    {
                        IHttpHandlerFactory factory = (IHttpHandlerFactory)XamlHttpHandlerFactory.CreateInstance(type);
                        this.cachedResult = factory;
                        return(XamlHttpHandlerFactory.HandlerWrapper.Create(factory.GetHandler(context, requestType, url, pathTranslated), factory));
                    }
                    exception         = new ConfigurationErrorsException(System.Xaml.Hosting.SR.NotHttpHandlerType(url, this.hostedXamlType, type.FullName));
                    this.cachedResult = exception;
                    throw FxTrace.Exception.AsError(exception);
                }
                exception         = new ConfigurationErrorsException(System.Xaml.Hosting.SR.HttpHandlerForXamlTypeNotFound(url, this.hostedXamlType, "system.xaml.hosting/httpHandlers"));
                this.cachedResult = exception;
                throw FxTrace.Exception.AsError(exception);
            }