本文整理汇总了C#中this.AddElement方法的典型用法代码示例。如果您正苦于以下问题:C# this.AddElement方法的具体用法?C# this.AddElement怎么用?C# this.AddElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.AddElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetColumnProperty
public static XmlElement SetColumnProperty(this XmlElement element, string name, string value)
{
XmlElement columnElement = element["column"] ?? element.AddElement("column");
columnElement.WithAtt(name, value);
return element;
}
示例2: WriteSection
public static void WriteSection(this XmlElement parent, Section section)
{
var sectionElement = parent.AddElement(XmlConvert.EncodeName(section.Key));
sectionElement.SetAttribute(XmlConstants.Id, section.id);
if (section.ActiveCells.Count > 0)
{
var activeCellString = section.ActiveCells.Select(x => "{0}={1}".ToFormat(x.Key, x.Value)).Join(",");
sectionElement.SetAttribute(XmlConstants.ActiveCells, activeCellString);
}
section.Children.Each(child =>
{
if (child is Comment)
{
sectionElement.WriteComment(child.As<Comment>());
}
if (child is Step)
{
sectionElement.WriteStep(child.As<Step>());
}
});
}
示例3: WriteStep
public static void WriteStep(this XmlElement parent, Step step)
{
var element = parent.AddElement(step.Key);
step.Values.Each(pair => element.SetAttribute(pair.Key, pair.Value));
step.Collections.Each(element.WriteSection);
}
示例4: AddElementEx
public static VA.Text.Markup.TextElement AddElementEx(this VA.Text.Markup.TextElement p, string text,
int? font, double? size, int? color,
VA.Drawing.AlignmentHorizontal? halign,
VA.Text.CharStyle? cs)
{
var el = p.AddElement(text);
if (font != null)
{
el.CharacterCells.Font = font.Value;
}
if (size.HasValue)
{
el.CharacterCells.Size = string.Format("{0}pt",size.Value);
}
if (color.HasValue)
{
var c = new VA.Drawing.ColorRGB(color.Value);
el.CharacterCells.Color = c.ToFormula();
}
if (halign.HasValue)
{
el.ParagraphCells.HorizontalAlign = (int) halign.Value;
}
if (cs.HasValue)
{
el.CharacterCells.Style = (int) cs;
}
return el;
}
示例5: Add
public static IHtmlElement Add(this IHtmlContainer container, XElement element )
{
var result = container.AddElement( element.Name.LocalName );
foreach ( var attribute in element.Attributes() )
result.SetAttribute( attribute.Name.LocalName, attribute.Value );
return result;
}
示例6: SetAttributeOnChild
public static void SetAttributeOnChild(this XmlElement element, string childName, string attName, string attValue)
{
XmlElement childElement = element[childName];
if (childElement == null)
{
childElement = element.AddElement(childName);
}
childElement.SetAttribute(attName, attValue);
}
示例7: EnsureEntityContainer
public static EdmEntityContainer EnsureEntityContainer(this EdmModel model, Type apiType)
{
var container = (EdmEntityContainer)model.EntityContainer;
if (container == null)
{
container = new EdmEntityContainer(apiType.Namespace, DefaultEntityContainerName);
model.AddElement(container);
}
return container;
}
示例8: AddFile
/// <summary>
/// Add a new <see cref="IPostDataElement"/> that represents the specified file
/// </summary>
/// <param name="postData">post data instance</param>
/// <param name="fileName">file name</param>
public static void AddFile(this IPostData postData, string fileName)
{
if(string.IsNullOrEmpty(fileName))
{
throw new ArgumentNullException("fileName");
}
var element = postData.CreatePostDataElement();
element.File = fileName;
postData.AddElement(element);
}
示例9: AddElement
/// <summary>
/// 在容器末尾增加一个元素
/// </summary>
/// <param name="modifier">DOM 结构修改器</param>
/// <param name="container">要添加元素的容器</param>
/// <param name="elementName">元素名</param>
/// <returns>添加的元素</returns>
public static IHtmlElement AddElement( this IHtmlDomModifier modifier, IHtmlContainer container, string elementName )
{
if ( modifier == null )
throw new ArgumentNullException( "modifier" );
if ( container == null )
throw new ArgumentNullException( "container" );
if ( elementName == null )
throw new ArgumentNullException( "elementName" );
lock ( container.SyncRoot )
{
return modifier.AddElement( container, container.Nodes().Count(), elementName );
}
}
示例10: AddData
/// <summary>
/// Add a new <see cref="IPostDataElement"/> that represents the key and value
/// The data is encoded using
/// </summary>
/// <param name="postData">Post Data</param>
/// <param name="data">Data to be encoded for the post data element</param>
/// <param name="encoding">Specified Encoding. If null then <see cref="Encoding.Default"/> will be used</param>
public static void AddData(this IPostData postData, string data, Encoding encoding = null)
{
if (string.IsNullOrEmpty(data))
{
throw new ArgumentNullException("data");
}
if(encoding == null)
{
encoding = Encoding.Default;
}
var element = postData.CreatePostDataElement();
element.Bytes = encoding.GetBytes(data);
postData.AddElement(element);
}
示例11: AddReasonElement
private static void AddReasonElement(this XmlNode parent, TestResult result)
{
parent.AddElement("reason").AddElementWithCDataSection("message", result.Message);
}
示例12: AddFailureElement
private static void AddFailureElement(this XmlNode parent, TestResult result)
{
var thisNode = parent.AddElement("failure");
if (result.Message != null)
thisNode.AddElementWithCDataSection("message", result.Message);
if (result.StackTrace != null)
thisNode.AddElementWithCDataSection("stack-trace", result.StackTrace);
}
示例13: AddProperty
// Adds a property element and its contents
private static void AddProperty(this XmlNode parent, string key, object val)
{
if (parent == null)
throw new ArgumentNullException("parent");
if (val == null)
throw new ArgumentNullException("val");
var node = parent.AddElement("property");
node.AddAttribute("name", key);
node.AddAttribute("value", val.ToString());
}
示例14: AddProperties
//Adds a properties element and its contents
private static void AddProperties(this XmlNode parent, ITest test)
{
var properties = parent.AddElement("properties");
foreach (string key in test.Properties.Keys)
{
object propValue = test.Properties[key];
// NOTE: This depends on categories being the only multi-valued
// property. We can count on this because NUnit V2 is not
// being developed any further.
if (key == "_CATEGORIES")
foreach (string category in (IList)propValue)
properties.AddProperty(key, category);
else
properties.AddProperty(key, propValue);
}
// Special handling for empty _CATEGORIES prop
// which is sometimes created by NUnit V2
if (properties.ChildNodes.Count == 0)
parent.RemoveChild(properties);
}
示例15: AddElementWithCDataSection
/// <summary>
/// Adds the a new element as a child of an existing node and returns it.
/// A CDataSection is added to the new element using the data provided.
/// </summary>
/// <param name="node">The node to which the element should be added.</param>
/// <param name="name">The element name.</param>
/// <param name="data">The data for the CDataSection.</param>
/// <returns></returns>
private static XmlNode AddElementWithCDataSection(this XmlNode node, string name, string data)
{
XmlNode childNode = node.AddElement(name);
foreach (var section in EscapeCDataString(data))
childNode.AppendChild(node.OwnerDocument.CreateCDataSection(section));
return childNode;
}