Beispiel #1
0
 private static Task ProcessException(HttpContext context, WebDefaultXmlConfig defaultConfig,
                                      WebBasePage page, PageSourceInfo info, Exception exception)
 {
     if (exception is RedirectException redirectEx)
     {
         context.Response.Redirect(redirectEx.Url.ToString(), false);
         return(Task.FromResult(0));
     }
     else if (exception is ReLogOnException)
     {
         return(HandleException(defaultConfig.ReLogOnHandler,
                                GetWebHandler(page, context, info), page, exception));
     }
     else if (exception is ErrorPageException)
     {
         return(HandleException(defaultConfig.ErrorPageHandler,
                                GetWebHandler(page, context, info), page, exception));
     }
     else if (exception is ErrorOperationException)
     {
         return(HandleException(defaultConfig.ErrorOperationHandler,
                                GetWebHandler(page, context, info), page, exception));
     }
     else if (exception is ToolkitException)
     {
         return(HandleException(defaultConfig.ToolkitHandler,
                                GetWebHandler(page, context, info), page, exception));
     }
     else
     {
         return(HandleException(defaultConfig.ExceptionHandler,
                                GetWebHandler(page, context, info), page, exception));
     }
 }
Beispiel #2
0
        private static IHttpHandler CreateHanlderInfoCreator(PageSourceInfo info)
        {
            var handler = PlugInFactoryManager.CreateInstance <IHttpHandler>(
                HttpHandlerPlugInFactory.REG_NAME, info.Parser);

            return(handler);
        }
Beispiel #3
0
        public static IModule CreateModule(this PageSourceInfo info)
        {
            TkDebug.AssertArgumentNull(info, "info", null);

            IModuleCreator moduleCreator = PlugInFactoryManager.CreateInstance <IModuleCreator>(
                ModuleCreatorPlugInFactory.REG_NAME, info.ModuleCreator);

            return(moduleCreator.Create(info.Source));
        }
Beispiel #4
0
        private static PageSourceInfo ParseUrl(string[] input, PageSourceInfo info)
        {
            if (input.Length >= 3)
            {
                bool   isContent     = true;
                string moduleCreator = input[0];
                if (string.IsNullOrEmpty(moduleCreator))
                {
                    moduleCreator = "xml";
                }
                else if (moduleCreator.StartsWith('~'))
                {
                    isContent     = false;
                    moduleCreator = moduleCreator.Substring(1);
                }
                IPageStyle style  = input[1].Value <PageStyleClass>((PageStyleClass)PageStyle.List);
                string     source = string.Join('/', GetSourceParts(input));
                info = new PageSourceInfo(REG_NAME, moduleCreator, style, source, isContent);
            }

            return(info);
        }
Beispiel #5
0
        public Task ProcessRequest(HttpContext context, RequestDelegate next, PathStringParser parser)
        {
            PageSourceInfo info = null;

            parser.Parse((input) =>
            {
                info = ParseUrl(input, info);
            });
            if (info == null)
            {
                return(null);
            }

            context.Items[WebUtil.SOURCE_INFO] = info;

            WebDefaultXmlConfig defaultConfig = WebGlobalVariable.WebCurrent.WebDefaultValue;
            WebBasePage         page          = null;

            try
            {
                if (info.IsContent)
                {
                    page = new WebModuleContentPage(context, next, info);
                }
                else
                {
                    page = new WebModuleRedirectPage(context, next, info);
                }
                return(page.LoadPage());
            }
            catch (RedirectException ex)
            {
                context.Response.Redirect(ex.Url.ToString(), false);
                return(Task.FromResult(0));
            }
            catch (ReLogOnException ex)
            {
                return(HandleException(defaultConfig.ReLogOnHandler,
                                       GetWebHandler(page, context, info), page, ex));
            }
            catch (ErrorPageException ex)
            {
                return(HandleException(defaultConfig.ErrorPageHandler,
                                       GetWebHandler(page, context, info), page, ex));
            }
            catch (ErrorOperationException ex)
            {
                return(HandleException(defaultConfig.ErrorOperationHandler,
                                       GetWebHandler(page, context, info), page, ex));
            }
            catch (ToolkitException ex)
            {
                return(HandleException(defaultConfig.ToolkitHandler,
                                       GetWebHandler(page, context, info), page, ex));
            }
            catch (Exception ex)
            {
                Exception innerEx = ex.InnerException;
                if (innerEx != null)
                {
                    return(ProcessException(context, defaultConfig, page, info, innerEx));
                }
                else
                {
                    return(ProcessException(context, defaultConfig, page, info, ex));
                }
            }
        }
Beispiel #6
0
 private static IWebHandler GetWebHandler(IWebHandler page, HttpContext context,
                                          PageSourceInfo info)
 {
     return(page ?? new ContextWebHandler(context, info));
 }
Beispiel #7
0
 public ContextWebHandler(HttpContext context, PageSourceInfo info, IPageStyle style)
 {
     fContext = context;
     fInfo    = info;
     fStyle   = style;
 }
Beispiel #8
0
 public ContextWebHandler(HttpContext context, PageSourceInfo info)
     : this(context, info, info.Style)
 {
 }