当前位置: 首页>>代码示例>>C#>>正文


C# HtmlTextWriter.Tag方法代码示例

本文整理汇总了C#中System.Web.UI.HtmlTextWriter.Tag方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.Tag方法的具体用法?C# HtmlTextWriter.Tag怎么用?C# HtmlTextWriter.Tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.HtmlTextWriter的用法示例。


在下文中一共展示了HtmlTextWriter.Tag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestListSection

 public TestListSection(List<NunitGoTest> tests)
 {
     var treeCode = Tree.GetTreeCode(tests);
     var stringWriter = new StringWriter();
     using (var writer = new HtmlTextWriter(stringWriter))
     {
         writer
             .Tag(HtmlTextWriterTag.Div,
                 () => writer
                     .Float("right")
                     .Div(() => writer
                         .DangerButton("Back", Output.Files.FullReportFile)
                     )
             )
             .Tag(HtmlTextWriterTag.Div, () => writer
                 .Write(treeCode)
             );
     }
     HtmlCode = stringWriter.ToString();
 }
开发者ID:elv1s42,项目名称:NUnitGo,代码行数:20,代码来源:TestListSection.cs

示例2: GetMailBody

        public static string GetMailBody(NunitGoTest nunitGoTest, bool addLinks, 
            bool isEventEmail = false, string eventName = "", TestEvent previousRunEvent = null)
        {
            var strWr = new StringWriter();
            using (var writer = new HtmlTextWriter(strWr))
            {
                writer.Write("<!DOCTYPE html>");
                writer.Write(Environment.NewLine);
                writer.RenderBeginTag(HtmlTextWriterTag.Head);
                writer.Tag(HtmlTextWriterTag.Meta, new Dictionary<string, string>
                {
                    {"http-equiv", "X-UA-Compatible"},
                    {"content", @"IE=edge"},
                    {"charset", "utf-8"}
                });
                writer.Tag(HtmlTextWriterTag.Title, "NUnitGo Email");
                writer.Tag(HtmlTextWriterTag.Style, new Dictionary<HtmlTextWriterAttribute, string>
                {
                    {HtmlTextWriterAttribute.Type, @"text/css"}
                });
                writer.Tag(HtmlTextWriterTag.Link, new Dictionary<HtmlTextWriterAttribute, string>
                {
                    {HtmlTextWriterAttribute.Rel, @"stylesheet"},
                    {HtmlTextWriterAttribute.Type, @"text/css"}
                });
                writer.RenderEndTag(); //HEAD

                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, Colors.White);
                writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "10px");
                writer.AddStyleAttribute("border", "10px solid " + Colors.TestBorderColor);
                writer.AddStyleAttribute(HtmlTextWriterStyle.Margin, "0px");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%");
                writer.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, "Tahoma,Verdana,Segoe,sans-serif");
                writer.RenderBeginTag(HtmlTextWriterTag.Body);

                writer.AddStyleAttribute("box-sizing", "border-box");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "auto");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Top, "0%");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%");
                writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "10px");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "test-window");
                writer.AddAttribute(HtmlTextWriterAttribute.Title, "Test");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "10px");
                writer.AddAttribute(HtmlTextWriterAttribute.Id, nunitGoTest.Guid.ToString());
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.AddTag(HtmlTextWriterTag.B, "Test full name: ");
                writer.Write(nunitGoTest.FullName);
                writer.RenderEndTag(); //P

                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.AddTag(HtmlTextWriterTag.B, "Test name: ");
                writer.Write(nunitGoTest.Name);
                writer.RenderEndTag(); //P

                if (isEventEmail && previousRunEvent != null)
                {
                    var currentEvent = nunitGoTest.Events.First(x => x.Name.Equals(eventName));
                    writer.RenderBeginTag(HtmlTextWriterTag.P);
                    writer.AddTag(HtmlTextWriterTag.B, "Event name: ");
                    writer.Write(currentEvent.Name);
                    writer.RenderEndTag(); //P
                    writer.RenderBeginTag(HtmlTextWriterTag.P);
                    writer.AddTag(HtmlTextWriterTag.B, string.Format("Current duration (event finished at {0}): ", currentEvent.Finished));
                    writer.Write(TimeSpan.FromSeconds(currentEvent.Duration).ToString(@"hh\:mm\:ss\:fff"));
                    writer.RenderEndTag(); //P
                    writer.RenderBeginTag(HtmlTextWriterTag.P);
                    writer.AddTag(HtmlTextWriterTag.B, string.Format("Previous duration (event finished at {0}): ", previousRunEvent.Finished));
                    writer.Write(TimeSpan.FromSeconds(previousRunEvent.Duration).ToString(@"hh\:mm\:ss\:fff"));
                    writer.RenderEndTag(); //P
                    writer.RenderBeginTag(HtmlTextWriterTag.P);
                    writer.AddTag(HtmlTextWriterTag.B, "Difference: ");
                    writer.Write(TimeSpan.FromSeconds(currentEvent.Duration - previousRunEvent.Duration).ToString(@"hh\:mm\:ss\:fff"));
                    writer.RenderEndTag(); //P
                }

                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, nunitGoTest.GetColor());
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.RenderBeginTag(HtmlTextWriterTag.B);
                writer.Write("Test result: ");
                writer.RenderEndTag(); //B
                writer.Write(nunitGoTest.Result);
                writer.RenderEndTag(); //P

                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.AddTag(HtmlTextWriterTag.B, "Test duration: ");
                writer.Write(TimeSpan.FromSeconds(nunitGoTest.TestDuration).ToString(@"hh\:mm\:ss\:fff"));
                writer.RenderEndTag(); //P

                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.AddTag(HtmlTextWriterTag.B, "Time period: ");
                var start = nunitGoTest.DateTimeStart.ToString("dd.MM.yy HH:mm:ss.fff");
                var end = nunitGoTest.DateTimeFinish.ToString("dd.MM.yy HH:mm:ss.fff");
                writer.Write(start + " - " + end);
                writer.RenderEndTag(); //P

                writer.RenderBeginTag(HtmlTextWriterTag.P);
//.........这里部分代码省略.........
开发者ID:elv1s42,项目名称:NUnitGo,代码行数:101,代码来源:MailGenerator.cs

示例3: GeneratePageString

        private void GeneratePageString()
        {
            var strWr = new StringWriter();
            using (var writer = new HtmlTextWriter(strWr))
            {
                writer
                    .WriteString("<!DOCTYPE html>")
                    .NewLine()
                    .Tag(HtmlTextWriterTag.Head, () => writer
                        .Tag(HtmlTextWriterTag.Meta, new Dictionary<string, string>
                        {
                            {"http-equiv", "X-UA-Compatible"},
                            {"content", @"IE=edge"},
                            {"charset", "utf-8"}
                        })
                        .Title(PageTitle)
                        .Scripts(ScriptFilePaths)
                        .TagIf(!PageScriptString.Equals(""), HtmlTextWriterTag.Script, PageScriptString)
                        .Type(@"text/css")
                        .Tag(HtmlTextWriterTag.Style)
                        .Stylesheets(PageStylePaths)

                    )
                    .Tag(HtmlTextWriterTag.Body, () => writer
                        .Class("border-bottom p-3 mb-3 bg-gray")
                        .Div(() => writer
                            .Class("container")
                            .Div(() => writer
                                .TextAlign("center")
                                .Div(() => writer
                                    .H1(PageTitle)
                                )
                            )
                        )
                        .Class("container")
                        .Tag(HtmlTextWriterTag.Div, () => writer
                            .Write(PageBodyCode)
                        )
                    )
                    .NewLine()
                    .Footer(FooterSection.HtmlCode)
                    .NewLine()
                    .WriteString("</html>")
                    .NewLine();
            }
            FullPage = strWr.ToString();
        }
开发者ID:elv1s42,项目名称:NUnitGo,代码行数:47,代码来源:HtmlPage.cs


注:本文中的System.Web.UI.HtmlTextWriter.Tag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。