本文整理汇总了C#中System.Xml.XmlElement.AddElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.AddElement方法的具体用法?C# XmlElement.AddElement怎么用?C# XmlElement.AddElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlElement
的用法示例。
在下文中一共展示了XmlElement.AddElement方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteLink
public void WriteLink(XmlElement parent, Link link)
{
var element = parent.AddElement("link").WithAtt("href", link.Url);
link.Title.IfNotNull(x => element.WithAtt("title", x));
link.Rel.IfNotNull(x => element.WithAtt("rel", x));
link.ContentType.IfNotNull(x => element.WithAtt("type", x));
}
示例2: Write
public void Write(XmlElement classElement, IMappingModelVisitor visitor)
{
XmlElement filterElement = classElement.AddElement("filter");
filterElement.SetAttribute("name", Name);
if (!string.IsNullOrEmpty(Condition))
{
filterElement.SetAttribute("condition", Condition);
}
}
示例3: HandleContact
void HandleContact(XmlElement contactsXml, Contact contact)
{
var contactXml = contactsXml.AddElement("Contact");
contactXml.SetAttribute("href", string.Format("{0}/contacts/{1}", this.baseUri, contact.ContactId));
contactXml.AddElement("Name", contact.Name);
contactXml.AddElement("Address", contact.Address);
contactXml.AddElement("City", contact.City);
contactXml.AddElement("State", contact.State);
contactXml.AddElement("Zip", contact.Zip);
contactXml.AddElement("Email", contact.Email);
HandleTwitter(contactXml, contact);
}
示例4: HandleQueries
void HandleQueries(XmlElement root)
{
var queriesXml = root.AddElement("Queries");
var twitterContactsXml = queriesXml.AddElement("Query");
twitterContactsXml.SetAttribute("name", "query-twitter-contacts");
twitterContactsXml.SetAttribute("href", string.Format("{0}/contacts/twitter", this.baseUri));
var searchXml = queriesXml.AddElement("Query");
searchXml.SetAttribute("name", "query-search");
searchXml.SetAttribute("href", string.Format("{0}/contacts/search", this.baseUri));
searchXml.AddElement("Field", "Name");
}
示例5: ParseProcessorDefinitions
private static void ParseProcessorDefinitions([NotNull] XmlNodeList processorNodes, [NotNull] List<ProcessorDefinition> processorDefinitions, XmlElement parentNode)
{
Assert.ArgumentNotNull(processorNodes, "processorNodes");
Assert.ArgumentNotNull(processorDefinitions, "processorDefinitions");
foreach (XmlElement processorElement in processorNodes.OfType<XmlElement>())
{
ProcessorDefinition definition = ParseProcessorDefinition(processorElement);
var definitionNode = parentNode.AddElement("processor");
definitionNode.SetAttribute("type", definition.Type.FullName);
definitionNode.SetAttribute("title", definition.Title);
definitionNode.SetAttribute("process", definition.ProcessAlways ? "always" : "once");
definitionNode.SetAttribute("param", definition.Param);
// add nested processor definitions
ParseProcessorDefinitions(processorElement.ChildNodes, definition.NestedProcessorDefinitions, definitionNode);
processorDefinitions.Add(definition);
}
}
示例6: AddTemplateVariants
private void AddTemplateVariants(XmlElement template)
{
XmlDocument ownerDocument = template.OwnerDocument;
XmlElement templateVariants = template.AddElement("TEMPLATEVARIANTS");
foreach (ITemplateVariant curTemplateVariant in TemplateVariants)
{
XmlElement templateVariant = templateVariants.AddElement("TEMPLATEVARIANT");
templateVariant.AddAttribute("name", curTemplateVariant.Name);
// ReSharper disable PossibleNullReferenceException
XmlText textNode = ownerDocument.CreateTextNode(curTemplateVariant.Data);
// ReSharper restore PossibleNullReferenceException
templateVariant.AppendChild(textNode);
}
}
示例7: AddTemplateDescriptions
private void AddTemplateDescriptions(IProject project, XmlElement template)
{
XmlElement templateDescriptions = template.AddElement("TEMPLATEDESCRIPTIONS");
foreach (ILanguageVariant languageVariant in project.LanguageVariants)
{
XmlElement templateDescription = templateDescriptions.AddElement("TEMPLATEDESCRIPTION");
templateDescription.AddAttribute("dialoglanguageid", languageVariant.Abbreviation);
templateDescription.AddAttribute("name", Name);
if (!string.IsNullOrEmpty(DescriptionInCurrentDisplayLanguage))
{
templateDescription.AddAttribute("description", DescriptionInCurrentDisplayLanguage);
}
}
}
示例8: AddProjectVariants
private void AddProjectVariants(IProject project, XmlElement template)
{
XmlElement projectVariants = template.AddElement("PROJECTVARIANTS");
projectVariants.AddAttribute("action", "assign");
foreach (IProjectVariant curVariant in Project.ProjectVariants)
{
XmlElement projectVariant = projectVariants.AddElement("PROJECTVARIANT");
IProjectVariant otherVariant;
if (!project.ProjectVariants.TryGetByName(curVariant.Name, out otherVariant))
{
throw new SmartAPIException(Session.ServerLogin,
string.Format("Could not find project variant {0} in project {1}",
curVariant.Name, project.Name));
}
projectVariant.AddAttribute("guid", otherVariant.Guid.ToRQLString());
}
}
示例9: Write
public void Write(XmlElement classElement, IMappingVisitor visitor)
{
var versionElement = classElement
.AddElement("version")
.WithProperties(properties);
if (neverGenerated)
{ versionElement.WithAtt("generated", "never"); }
if (Property.PropertyType == typeof(DateTime))
{ versionElement.WithAtt("type", "timestamp"); }
}
示例10: Write
public void Write(XmlElement classElement, IMappingVisitor visitor)
{
XmlElement element = classElement.AddElement("id")
.WithAtt("name", property.Name)
.WithAtt("type", TypeMapping.GetTypeString(property.PropertyType));
if (unsavedValue != null)
element.WithAtt("unsaved-value", unsavedValue.ToString());
elementAttributes.ForEachPair((name, value) => element.WithAtt(name, value));
XmlElement generatorElement = element.AddElement("generator").WithAtt("class", GeneratorClass);
generatorParameters.ForEachPair(
(name, innerXml) => generatorElement.AddElement("param").WithAtt("name", name).InnerXml = innerXml);
}
示例11: HandleTwitter
void HandleTwitter(XmlElement contactXml, Contact contact)
{
if (contact.Twitter != null)
{
var twitterXml = contactXml.AddElement("Twitter");
twitterXml.SetAttribute("user", "gblock"); // SB logged-in user
var tweetsXml = twitterXml.AddElement("Tweets");
tweetsXml.SetAttribute("href", string.Format("{0}/contacts/{1}/tweets", this.baseUri, contact.ContactId));
var dmXml = twitterXml.AddElement("DM");
var field = dmXml.AddElement("Field", "Message");
dmXml.SetAttribute("href", string.Format("{0}/contacts/{1}/dm", this.baseUri, contact.ContactId)); ;
var mentionXml = twitterXml.AddElement("Mention");
field = mentionXml.AddElement("Field", "Message");
mentionXml.SetAttribute("href", string.Format("{0}/contacts/{1}/mention", this.baseUri, contact.ContactId));
}
}
示例12: Write
public void Write(XmlElement classElement, IMappingVisitor visitor)
{
if (!IsDirty) return;
var cacheElement = classElement.AddElement("cache")
.WithAtt("usage", usage);
if (!string.IsNullOrEmpty(region))
cacheElement.WithAtt("region", region);
cacheElement.WithProperties(attributes);
}