Beispiel #1
0
        static MessageModel()
        {
            MESSAGE_RENDERER.OuterTagName = "div";
            MESSAGE_RENDERER.InnerTagName = "span";

            MESSAGE_RENDERER.AppendOuterAttributeValue(FeedbackMessageLevel.INFO, "class", "ui info message MessageModel");
            MESSAGE_RENDERER.AppendOuterAttributeValue(FeedbackMessageLevel.SUCCESS, "class", "ui success message MessageModel");
            MESSAGE_RENDERER.AppendOuterAttributeValue(FeedbackMessageLevel.WARN, "class", "ui warn message MessageModel");
            MESSAGE_RENDERER.AppendOuterAttributeValue(FeedbackMessageLevel.ERROR, "class", "ui error message MessageModel");
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseSession();
            app.UseFeedackMessages();

            FeedbackMessageSettings.CreateInitializer()
            .SetMessageRendererFactory(() =>
            {
                var messageRenderer          = new FeedbackMessageRenderer();
                messageRenderer.OuterTagName = "div";
                messageRenderer.InnerTagName = "span";

                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.INFO, "class", "ui info message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.SUCCESS, "class", "ui success message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.WARN, "class", "ui warning message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.ERROR, "class", "ui error message");

                return(messageRenderer);
            })
            .SetScriptBuilderInstance(new FeedbackMessageScriptBuilder(msg => $"alert('{msg.ToString()}');"))
            .Initialize();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "Second",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Beispiel #3
0
        public void TestAppendAttributeValue()
        {
            InitializeHttpContext();

            InfoMessage("TestMessage");


            var renderer = new FeedbackMessageRenderer();

            renderer.OuterTagName = "div";
            renderer.InnerTagName = "div";

            renderer.AppendOuterAttributeValue("id", "outer");
            renderer.AppendInnerAttributeValue("id", "inner");

            {
                var htmlString = renderer.RenderMessages().ToString();
                var htmlParser = new HtmlParser();

                var htmlDoc = htmlParser.ParseDocument(htmlString);
                var outer   = htmlDoc.GetElementById("outer");
                Assert.IsNotNull(outer);
                var inner = htmlDoc.GetElementById("inner");
                Assert.IsNotNull(inner);
            }



            renderer.AppendOuterAttributeValue("class", "outer");
            renderer.AppendInnerAttributeValue("class", "inner");

            {
                var htmlString = renderer.RenderMessages().ToString();
                var htmlParser = new HtmlParser();

                var htmlDoc = htmlParser.ParseDocument(htmlString);
                var outer   = htmlDoc.GetElementById("outer");
                Assert.IsNotNull(outer);
                Assert.IsTrue(outer.Attributes["class"].Value.Contains("outer"));
                var inner = htmlDoc.GetElementById("inner");
                Assert.IsNotNull(inner);
                Assert.IsTrue(inner.Attributes["class"].Value.Contains("inner"));
            }
        }
Beispiel #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseSession();
            app.UseFeedackMessages();

            FeedbackMessageSettings.CreateInitializer()
            .SetMessageRendererFactory(() =>
            {
                var messageRenderer          = new FeedbackMessageRenderer();
                messageRenderer.OuterTagName = "div";
                messageRenderer.InnerTagName = "p";

                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.INFO, "class", "ui info message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.SUCCESS, "class", "ui success message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.WARN, "class", "ui warning message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.ERROR, "class", "ui error message");

                return(messageRenderer);
            })
            .SetScriptBuilderInstance(new FeedbackMessageScriptBuilder(msg => $"alert('{msg.ToString()}');"))
            .Initialize();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");
            });
        }
Beispiel #5
0
        void Application_Start(object sender, EventArgs e)
        {
            // アプリケーションのスタートアップで実行するコードです
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            FeedbackMessageSettings.CreateInitializer()
            .SetMessageRendererFactory(() =>
            {
                var messageRenderer          = new FeedbackMessageRenderer();
                messageRenderer.OuterTagName = "div";
                messageRenderer.InnerTagName = "span";

                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.INFO, "class", "ui info message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.SUCCESS, "class", "ui success message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.WARN, "class", "ui warning message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.ERROR, "class", "ui error message");

                return(messageRenderer);
            })
            .SetScriptBuilderInstance(new FeedbackMessageScriptBuilder(msg => $"alert('{msg.ToString()}');"))
            .Initialize();
        }
Beispiel #6
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            FeedbackMessageSettings.CreateInitializer()
            .SetMessageRendererFactory(() =>
            {
                var messageRenderer          = new FeedbackMessageRenderer();
                messageRenderer.OuterTagName = "div";
                messageRenderer.InnerTagName = "span";

                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.INFO, "class", "ui info message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.SUCCESS, "class", "ui success message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.WARN, "class", "ui warning message");
                messageRenderer.AppendOuterAttributeValue(FeedbackMessageLevel.ERROR, "class", "ui error message");

                return(messageRenderer);
            })
            .SetScriptBuilderInstance(new FeedbackMessageScriptBuilder(msg => $"alert('{msg.ToString()}');"))
            .Initialize();
        }
Beispiel #7
0
        public void TestRenderMessagesMultiMessage()
        {
            InitializeHttpContext();

            InfoMessage("TestMessage1");
            InfoMessage("TestMessage2");

            var renderer = new FeedbackMessageRenderer();

            renderer.OuterTagName = "div";
            renderer.InnerTagName = "div";

            renderer.AppendOuterAttributeValue("id", "outer");



            var htmlString = renderer.RenderMessages().ToString();

            var htmlParser = new HtmlParser();
            var htmlDoc    = htmlParser.ParseDocument(htmlString);


            var outer = htmlDoc.GetElementById("outer");

            Assert.IsNotNull(outer);
            Assert.AreEqual("div", outer.NodeName.ToLower());
            Assert.IsTrue(outer.Attributes["class"].Value.Contains("feedback-info"));


            Assert.AreEqual(2, outer.ChildElementCount);

            var mes1 = outer.FirstChild;

            Assert.IsNotNull(mes1);
            Assert.AreEqual("div", mes1.NodeName.ToLower());
            Assert.AreEqual("TestMessage1", mes1.TextContent);

            var mes2 = mes1.NextSibling;

            Assert.IsNotNull(mes2);
            Assert.AreEqual("div", mes2.NodeName.ToLower());
            Assert.AreEqual("TestMessage2", mes2.TextContent);
        }