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


C# HtmlTag.AddChildren方法代码示例

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


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

示例1: MakeRadioButton

 private static HtmlTag MakeRadioButton(string display, object value, string name)
 {
     DivTag divTag = new DivTag(display);
     HtmlTag radioButton = new RadioButtonTag(false).Attr("value", value).Attr("name",name);
     HtmlTag label = new HtmlTag("label").Text(display);
     label.AddChildren(radioButton);
     divTag.AddChildren(label);
     return divTag;
 }
开发者ID:reharik,项目名称:KnowYourTurf,代码行数:9,代码来源:RadioButtonListTag.cs

示例2: BuildDocument

        public static HtmlDocument BuildDocument(IUrlRegistry urls, string title, params HtmlTag[] tags)
        {
            var css = GetResourceText(typeof(BehaviorGraphWriter), "diagnostics.css");

            var realTitle = "FubuMVC: " + title;

            var document = new HtmlDocument();
            document.Title = realTitle;

            var mainDiv = new HtmlTag("div").AddClass("main");
            mainDiv.Add("h2").Text("FubuMVC Diagnostics").Child(buildVersionTag());
            var navBar = mainDiv.Add("div").AddClass("homelink");
            navBar.AddChildren(new LinkTag("Home", urls.UrlFor<BehaviorGraphWriter>(w => w.Index())));
            navBar.Add("span").Text(" > " + title);
            document.Add(mainDiv);

            mainDiv.AddChildren(tags);

            document.AddStyle(css);

            return document;
        }
开发者ID:joshuaflanagan,项目名称:fubumvc,代码行数:22,代码来源:DiagnosticHtml.cs

示例3: Example

        public HtmlDocument Example(ExampleHtmlRequest exampleHtmlRequest)
        {
            var modelPath = exampleHtmlRequest.Model ?? typeof(ExampleViewModel).FullName + "-Person";
            var tags = new List<HtmlTag>();
            var propertyPath = new List<string>(modelPath.Split('-'));
            var rootModelTypeName = propertyPath[0];
            tags.Add(new HtmlTag("h3").AddClass("viewmodel").Text(propertyPath.Join(".")));
            propertyPath.RemoveAt(0);

            Type scannedModelType = getTypeFromName(rootModelTypeName);
            var scannedModelInstance = createInstance(scannedModelType);
            var tagGeneratorType = typeof(TagGenerator<>).MakeGenericType(scannedModelType);
            var tagGenerator = (ITagGenerator)_serviceLocator.GetInstance(tagGeneratorType);
            tagGenerator.SetModel(scannedModelInstance);

            var propertyChainParts = new List<PropertyInfo>();

            while (propertyPath.Count > 0)
            {
                var parentPropertyInfo = scannedModelType.GetProperty(propertyPath[0]);
                propertyChainParts.Add(parentPropertyInfo);
                var currentModelType = parentPropertyInfo.PropertyType;
                var currentModel = createInstance(currentModelType);
                setProperty(parentPropertyInfo, scannedModelInstance, currentModel);

                scannedModelType = currentModelType;
                scannedModelInstance = currentModel;
                propertyPath.RemoveAt(0);
            }

            var modelProperties = scannedModelType.GetProperties();
            var propertiesToLink = modelProperties.Where(p => !TypeDescriptor.GetConverter(p.PropertyType).CanConvertFrom(typeof(string)));
            var propertiesToShow = modelProperties.Except(propertiesToLink);

            // show links to deeper properties
            var linkList = new HtmlTag("ul").AddClass("subproperties");
            foreach (var propertyInfo in propertiesToLink)
            {
                var linkTag = new LinkTag("", _examplePageUrl + "?model=" + modelPath + "-" + propertyInfo.Name);
                linkTag.Child(new HtmlTag("code").Text(getPropertySourceCode(propertyInfo)));
                var listItem = new HtmlTag("li").Child(linkTag);
                linkList.Child(listItem);
            }
            if (linkList.Children.Count > 0) tags.Add(linkList);

            // show examples
            populateInstance(scannedModelInstance, propertiesToShow);
            foreach (var propertyInfo in propertiesToShow)
            {
                var property = propertyChainParts.Count > 0 ?
                    (Accessor) new PropertyChain(propertyChainParts.Concat(new[]{propertyInfo}).ToArray()) :
                    new SingleProperty(propertyInfo);

                var propertyExpression = "x => x." + property.PropertyNames.Join(".");

                var propertySource = getPropertySourceCode(propertyInfo);

                var example = new HtmlTag("div").AddClass("example");
                example.AddChildren(new HtmlTag("code").AddClass("property").Text(propertySource));
                example.AddChildren(createExample(tagGenerator.LabelFor(tagGenerator.GetRequest(property)), "LabelFor({0})".ToFormat(propertyExpression)));
                example.AddChildren(createExample(tagGenerator.DisplayFor(tagGenerator.GetRequest(property)), "DisplayFor({0})".ToFormat(propertyExpression)));
                example.AddChildren(createExample(tagGenerator.InputFor(tagGenerator.GetRequest(property)), "InputFor({0})".ToFormat(propertyExpression)));
                tags.Add(example);
            }

            var doc = DiagnosticHtml.BuildDocument(_urlRegistry, "FubuMVC.UI Examples", tags.ToArray());
            doc.AddStyle(DiagnosticHtml.GetResourceText(GetType(), "examples.css"));
            return doc;
        }
开发者ID:nhsevidence,项目名称:fubumvc,代码行数:69,代码来源:ExampleHtmlWriter.cs

示例4: createExample

 private static HtmlTag createExample(HtmlTag htmlTag, string methodCall)
 {
     var example = new HtmlTag("fieldset").AddClass("tag");
     example.Add("legend").Text(methodCall);
     example.AddChildren(new HtmlTag("code").AddClass("source").Text(htmlTag.ToString()));
     example.AddChildren(new HtmlTag("div").AddClass("rendered").AddChildren(htmlTag));
     return example;
 }
开发者ID:nhsevidence,项目名称:fubumvc,代码行数:8,代码来源:ExampleHtmlWriter.cs

示例5: Chain

        public HtmlDocument Chain(ChainRequest chainRequest)
        {
            var title = "Chain " + chainRequest.Id;

            var behaviorChain = _graph.Behaviors.FirstOrDefault(chain => chain.UniqueId == chainRequest.Id);
            if (behaviorChain == null)
            {
                return BuildDocument("Unknown chain", new HtmlTag("span").Text("No behavior chain registered with ID: " + chainRequest.Id));
            }

            var content = new HtmlTag("div").AddClass("main-content");

            var document = new HtmlTag("div");
            var pattern = behaviorChain.RoutePattern;
            if( pattern == string.Empty )
            {
                pattern = "(default)";
            }
            document.Child(new HtmlTag("div").Text("Route: " + pattern));

            var nodeTable = new TableTag();
            nodeTable.AddHeaderRow(header =>
            {
                header.Header("Category");
                header.Header("Description");
                header.Header("Type");
            });
            foreach (var node in behaviorChain)
            {

                var description = node.ToString().HtmlEncode().ConvertCRLFToBreaks();
                nodeTable.AddBodyRow(row =>
                {
                    row.Cell().Text(node.Category.ToString());
                    row.Cell().UnEncoded().Text(description);
                    row.Cell().Text(node.GetType().FullName);
                    if (description.Contains(_diagnosticsNamespace))
                    {
                        row.AddClass(FUBU_INTERNAL_CLASS);
                    }
               });
            }

            var logDiv = new HtmlTag("div").AddClass("convention-log");
            var ul = logDiv.Add("ul");

            var observer = _graph.Observer;
            behaviorChain.Calls.Each(
                call => observer.GetLog(call).Each(
                            entry => ul.Add("li").Text(entry)));

            content.AddChildren(new[]{
                document,
                new HtmlTag("h3").Text("Nodes:"),
                nodeTable,
                new HtmlTag("h3").Text("Log:"),
                logDiv});

            return BuildDocument(title, content);
        }
开发者ID:sbartlett,项目名称:fubumvc,代码行数:60,代码来源:BehaviorGraphWriter.cs


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