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


C# HtmlElement.Attributes方法代码示例

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


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

示例1: ReplaceAll

        public void ReplaceAll(HtmlObject[] content)
        {
            HtmlElement parent = new HtmlElement("parent", new HtmlElement("element"), new HtmlAttribute("attribute1"), new HtmlAttribute("attribute2"), new HtmlComment("comment"));

            parent.ReplaceAll(content);
            Assert.Equal(content.OfType<HtmlElement>().ToArray(), parent.Elements().ToArray());
            Assert.Equal(content.OfType<HtmlAttribute>().ToArray(), parent.Attributes().ToArray());
            Assert.Equal(parent.Elements().Count() + parent.Attributes().Count(), parent.ElementsAndAttributes().Count());
            Assert.Equal(parent.Nodes().Count() + parent.Attributes().Count(), parent.NodesAndAttributes().Count());
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:10,代码来源:HtmlElement.ReplaceTests.cs

示例2: Ctor_String_ParamsHtmlObject

 public void Ctor_String_ParamsHtmlObject(HtmlObject[] content)
 {
     HtmlElement element = new HtmlElement("element", content);
     Assert.Equal("element", element.Tag);
     Assert.False(element.IsVoid);
     Assert.Equal(content.OfType<HtmlElement>().ToArray(), element.Elements().ToArray());
     Assert.Equal(content.OfType<HtmlAttribute>().ToArray(), element.Attributes().ToArray());
     Assert.Equal(content.OfType<HtmlNode>().ToArray(), element.Nodes().ToArray());
     Assert.Equal(element.Elements().Count() + element.Attributes().Count(), element.ElementsAndAttributes().Count());
     Assert.Equal(content.Length, element.NodesAndAttributes().Count());
 }
开发者ID:hughbe,项目名称:html-generator,代码行数:11,代码来源:HtmlElementTests.cs

示例3: CreateTextArea

        public IHtmlNode CreateTextArea()
        {
            var element = new HtmlElement(editor.TagName).Attributes(new { name = editor.Name, id = editor.Id });
            var inline = editor.TagName != "textarea";

            if (inline)
            {
                element.Attribute("contentEditable", "true");
            }
            else
            {
                element.Attributes(new
                {
                    cols = "20",
                    rows = "5"
                });
            }

            element.Attributes(editor.GetUnobtrusiveValidationAttributes())
                   .Attributes(editor.HtmlAttributes);

            var value = editor.GetValue<string>(editor.Value);

            if (!string.IsNullOrEmpty(value))
            {
                if (inline)
                {
                    element.Html(value);
                }
                else
                {
                    element.Text(value);
                }
            }
            else if (editor.Content != null)
            {
                editor.Template.Apply(element);
            }
            else if (editor.Template.InlineTemplate != null)
            {
                var html = editor.Template.InlineTemplate(null).ToString();

                if (inline)
                {
                    element.Html(html);
                }
                else
                {
                    element.Text(html);
                }
            }

            return element;
        }
开发者ID:jstevenson81,项目名称:wodgeaux,代码行数:54,代码来源:EditorHtmlBuilder.cs

示例4: Add_HtmlObject

        public void Add_HtmlObject(bool isVoid)
        {
            HtmlElement parent = new HtmlElement("parent", isVoid);

            // Atribute
            HtmlAttribute attribute = new HtmlAttribute("attribute");
            parent.Add(attribute);
            Assert.Equal(parent, attribute.Parent);
            Assert.Equal(new HtmlAttribute[] { attribute }, parent.Attributes());

            if (!isVoid)
            {
                // Element
                HtmlElement element = new HtmlElement("element");
                parent.Add(element);
                Assert.Equal(parent, element.Parent);
                Assert.Equal(new HtmlElement[] { element }, parent.Elements());

                // Nodes
                HtmlComment comment = new HtmlComment("comment");
                parent.Add(comment);
                Assert.Equal(parent, comment.Parent);
                Assert.Equal(new HtmlObject[] { element, comment }, parent.Nodes());
            }
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:25,代码来源:HtmlElement.AddTests.cs

示例5: Add_ParamsHtmlObject_Empty

 public void Add_ParamsHtmlObject_Empty()
 {
     HtmlElement element = new HtmlElement("parent");
     element.Add(new HtmlObject[0]);
     Assert.Empty(element.Elements());
     Assert.Empty(element.Attributes());
 }
开发者ID:hughbe,项目名称:html-generator,代码行数:7,代码来源:HtmlElement.AddTests.cs

示例6: Apply

        public void Apply(IHtmlNode parent)
        {
            var span = new HtmlElement("span");

            span.Attributes(button.ImageHtmlAttributes).AddClass(UIPrimitives.Icon, button.SpriteCssClass);

            span.AppendTo(parent);
        }
开发者ID:vialpando09,项目名称:RallyPortal2,代码行数:8,代码来源:GridButtonImageDecorator.cs

示例7: Ctor_String

 public void Ctor_String(string tag, string expectedTag)
 {
     HtmlElement element = new HtmlElement(tag);
     Assert.Equal(expectedTag, element.Tag);
     Assert.False(element.IsVoid);
     Assert.Empty(element.Elements());
     Assert.Empty(element.Attributes());
     Assert.Empty(element.ElementsAndAttributes());
 }
开发者ID:hughbe,项目名称:html-generator,代码行数:9,代码来源:HtmlElementTests.cs

示例8: Ctor_String_Bool

 public void Ctor_String_Bool(string tag, bool isVoid, string expectedTag)
 {
     HtmlElement element = new HtmlElement(tag, isVoid);
     Assert.Equal(expectedTag, element.Tag);
     Assert.Equal(isVoid, element.IsVoid);
     Assert.Empty(element.Elements());
     Assert.Empty(element.Attributes());
     Assert.Empty(element.ElementsAndAttributes());
 }
开发者ID:hughbe,项目名称:html-generator,代码行数:9,代码来源:HtmlElementTests.cs

示例9: ReplaceAll_IEnumerableHtmlObject_AttributeToVoidElement

        public void ReplaceAll_IEnumerableHtmlObject_AttributeToVoidElement()
        {
            HtmlElement parent = new HtmlElement("parent", isVoid: true);
            parent.Add(new HtmlAttribute("attribute"));

            HtmlAttribute[] attributes = new HtmlAttribute[] { new HtmlAttribute("attribute1"), new HtmlAttribute("attribute2") };
            parent.ReplaceAll((IEnumerable<HtmlObject>)attributes);
            Assert.Equal(attributes, parent.Attributes());
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:9,代码来源:HtmlElement.ReplaceTests.cs

示例10: Add_ParamsHtmlObject_VoidElement

        public void Add_ParamsHtmlObject_VoidElement()
        {
            HtmlElement element = new HtmlElement("parent", isVoid: true);
            HtmlAttribute attribute1 = new HtmlAttribute("attribute1");
            HtmlAttribute attribute2 = new HtmlAttribute("attribute2");
            element.Add(new HtmlObject[] { attribute1, attribute2 });

            Assert.Equal(element, attribute1.Parent);
            Assert.Equal(element, attribute2.Parent);
            Assert.Empty(element.Elements());
            Assert.Equal(new HtmlAttribute[] { attribute1, attribute2 }, element.Attributes());
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:12,代码来源:HtmlElement.AddTests.cs

示例11: CreateFooterElement

        protected virtual void CreateFooterElement(IHtmlNode html)
        {
            if (component.Footer.HasValue())
            {
                var dom = new HtmlElement("footer")
                            .Attribute("data-role", "footer");

                component.Footer.Apply(dom);

                dom.Attributes(component.FooterHtmlAttributes);

                html.Children.Add(dom);
            }
        }
开发者ID:wanaxe,项目名称:Study,代码行数:14,代码来源:MobileLayoutHtmlBuilder.cs

示例12: Add_ParamsHtmlObject_NonVoidElement

        public void Add_ParamsHtmlObject_NonVoidElement()
        {
            HtmlElement parent = new HtmlElement("parent");
            HtmlElement element = new HtmlElement("element");
            HtmlAttribute attribute = new HtmlAttribute("attribute");
            HtmlComment comment = new HtmlComment("comment");
            parent.Add(new HtmlObject[] { element, attribute, comment });

            Assert.Equal(parent, element.Parent);
            Assert.Equal(parent, attribute.Parent);
            Assert.Equal(new HtmlObject[] { element }, parent.Elements());
            Assert.Equal(new HtmlAttribute[] { attribute }, parent.Attributes());
            Assert.Equal(new HtmlObject[] { element, comment }, parent.Nodes());
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:14,代码来源:HtmlElement.AddTests.cs

示例13: Create

        public virtual IHtmlNode Create(object dataItem)
        {
            var button = new HtmlElement(ButtonTagName);

            ApplyButtonAttributes(button, dataItem);

            button.Attributes(HtmlAttributes)
                  .AddClass(CssClass);

            foreach (var decorator in Decorators)
            {
                decorator.Apply(button);
            }

            return button;
        }
开发者ID:vialpando09,项目名称:RallyPortal2,代码行数:16,代码来源:GridButtonBuilderBase.cs

示例14: ReplaceAttributes_ParamsHtmlAttribute_VoidElement

        public void ReplaceAttributes_ParamsHtmlAttribute_VoidElement()
        {
            HtmlElement parent = new HtmlElement("parent", isVoid: true);
            parent.Add(new HtmlAttribute("attribute"));

            HtmlAttribute[] attributes = new HtmlAttribute[] { new HtmlAttribute("attribute1"), new HtmlAttribute("attribute2") };
            parent.ReplaceAttributes(attributes);
            Assert.Equal(attributes, parent.Attributes());
        }
开发者ID:hughbe,项目名称:html-generator,代码行数:9,代码来源:HtmlElement.ReplaceTests.cs

示例15: WithTabIndex

 public void WithTabIndex()
 {
     HtmlElement element = new HtmlElement("html");
     Assert.Same(element, element.WithTabIndex("value"));
     Assert.Equal(Attribute.TabIndex("value"), element.Attributes().First());
 }
开发者ID:hughbe,项目名称:html-generator,代码行数:6,代码来源:TagTests.cs


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