コード例 #1
0
ファイル: VirtualHostRouter.cs プロジェクト: fan92rus/GenHTTP
        public VirtualHostRouter(IHandler parent,
                                 Dictionary <string, IHandlerBuilder> hosts,
                                 IHandlerBuilder?defaultRoute)
        {
            Parent = parent;

            Hosts        = hosts.ToDictionary(kv => kv.Key, kv => kv.Value.Build(this));
            DefaultRoute = defaultRoute?.Build(this);
        }
コード例 #2
0
        internal CoreRouter(IHandlerBuilder content, IEnumerable <IConcernBuilder> concerns, bool development)
        {
            Content = Concerns.Chain(this, concerns, (p) => content.Build(p));

            Template = Placeholders.Template <TemplateModel>(Data.FromResource("Template.html"))
                       .Build();

            ErrorRenderer = Placeholders.Template <ErrorModel>(Data.FromResource(development ? "ErrorStacked.html" : "Error.html"))
                            .Build();
        }
コード例 #3
0
        public LayoutRouter(IHandler parent,
                            Dictionary <string, IHandlerBuilder> handlers,
                            IHandlerBuilder?index,
                            IHandlerBuilder?fallback)
        {
            Parent = parent;

            Handlers = handlers.ToDictionary(kv => kv.Key, kv => kv.Value.Build(this));

            Index    = index?.Build(this);
            Fallback = fallback?.Build(this);
        }
コード例 #4
0
ファイル: WebsiteRouter.cs プロジェクト: ondator/GenHTTP
        public WebsiteRouter(IHandler parent,
                             IHandlerBuilder content,
                             IEnumerable <IConcernBuilder> concerns,
                             IHandlerBuilder scripts,
                             IHandlerBuilder styles,
                             IResourceProvider?favicon,
                             IMenuProvider?menu,
                             ITheme theme)
        {
            Parent = parent;

            var layout = Layout.Create()
                         .Add("scripts", scripts)
                         .Add("styles", styles)
                         .Add("sitemap.xml", Sitemap.Create())
                         .Add("robots.txt", BotInstructions.Default().Sitemap())
                         .Fallback(content);

            foreach (var concern in concerns)
            {
                layout.Add(concern);
            }

            if (favicon != null)
            {
                layout.Add("favicon.ico", Download.From(favicon).Type(ContentType.ImageIcon));
            }

            if (theme.Resources != null)
            {
                layout.Add("resources", theme.Resources);
            }

            Handler = layout.Build(this);

            Theme = theme;

            Menu = menu ?? Websites.Menu.Create((r, _) => GetContent(r)).Build();

            var scriptRouter = (ScriptRouter)scripts.Build(this);
            var styleRouter  = (StyleRouter)styles.Build(this);

            Renderer = new WebsiteRenderer(Theme, Menu, scriptRouter, styleRouter);
        }
コード例 #5
0
ファイル: ContentTests.cs プロジェクト: fossabot/GenHTTP
 public IHandler WithParent(IHandler parent, IRequest _) => _Page.Build(parent);