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"); }
// 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?}"); }); }
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")); } }
// 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"); }); }
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(); }
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(); }
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); }