本文整理汇总了C#中System.Xml.XmlElement.SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.SetAttribute方法的具体用法?C# XmlElement.SetAttribute怎么用?C# XmlElement.SetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlElement
的用法示例。
在下文中一共展示了XmlElement.SetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveNotificationToXml
public override void SaveNotificationToXml(INotification notification, XmlElement notificationElement)
{
var n = notification as IconNotification;
notificationElement.SetAttribute("notificationText", n.NotificationText);
notificationElement.SetAttribute("flashIconPath", n.FlashIconPath);
notificationElement.SetAttribute("flashCount", n.FlashCount.ToString());
}
示例2: SaveXml
/// <summary>
/// Salva definições em um xml
/// </summary>
public override void SaveXml(XmlDocument doc, XmlElement element)
{
base.SaveXml (doc, element);
element.SetAttribute("prefixo", prefixo);
element.SetAttribute("sufixo", sufixo);
}
示例3: SaveCecilXml
internal void SaveCecilXml (XmlElement elem)
{
elem.SetAttribute ("name", name);
elem.SetAttribute ("type", type.FullName);
if (!canWrite)
elem.SetAttribute ("canWrite", "false");
}
示例4: MappingCondition
internal MappingCondition(EDMXFile parentFile, EntitySetMapping entitySetMapping, XmlElement entitySetMappingElement, ModelEntityType modelEntityType, StoreMemberProperty discriminatorColumn, string discriminatorValue)
: base(parentFile)
{
_entitySetMapping = entitySetMapping;
_modelEntityType = modelEntityType;
_discriminatorColumn = discriminatorColumn;
string storeEntitySetName = discriminatorColumn.EntityType.EntitySet.Name;
//get hold of the type mapping
_entityTypeMapping = (XmlElement)entitySetMappingElement.SelectSingleNode("map:EntityTypeMapping[@TypeName=" + XmlHelpers.XPathLiteral(modelEntityType.FullName) + " or @TypeName=" + XmlHelpers.XPathLiteral("IsTypeOf(" + modelEntityType.FullName + ")") + " or @TypeName=" + XmlHelpers.XPathLiteral(modelEntityType.AliasName) + " or @TypeName=" + XmlHelpers.XPathLiteral("IsTypeOf(" + modelEntityType.AliasName + ")") + "]", NSM);
if (_entityTypeMapping == null)
{
throw new ArgumentException("The entity type " + modelEntityType.Name + " is not a participant in this entity set mapping.");
}
_mappingFragment = (XmlElement)_entityTypeMapping.SelectSingleNode("map:MappingFragment[@StoreEntitySet=" + XmlHelpers.XPathLiteral(storeEntitySetName) + "]", NSM);
if (_mappingFragment == null)
{
throw new ArgumentException("The store entityset " + storeEntitySetName + " is not a participant in this entity set mapping.");
}
_mappingCondition = EDMXDocument.CreateElement("Condition", NameSpaceURImap);
_mappingCondition.SetAttribute("ColumnName", discriminatorColumn.Name);
if (discriminatorValue != null)
{
_mappingCondition.SetAttribute("Value", discriminatorValue);
}
else
{
_mappingCondition.SetAttribute("IsNull", "true");
}
_mappingFragment.AppendChild(_mappingCondition);
}
示例5: PropsToXmlAttr
/// <summary>
/// Assigns each property of a class to an XML attribute for a given Element
/// </summary>
/// <param name="doc">XmlDocument used to create elements</param>
/// <param name="obj">Class whose properties are to be serialized</param>
/// <param name="elem">Element to add attributes to</param>
/// <returns>The same XmlElement, for brevity of code</returns>
static XmlElement PropsToXmlAttr(XmlDocument doc, object obj, XmlElement elem)
{
foreach (PropertyInfo pi in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance))
{
if (pi.GetValue(obj) != null && pi.GetValue(obj).ToString() != "")
{
DefaultValueAttribute dvAttr = (DefaultValueAttribute)Attribute.GetCustomAttribute(pi, typeof(DefaultValueAttribute));
if (dvAttr == null)
{
elem.SetAttribute(pi.Name, pi.GetValue(obj).ToString());
}
else
{
if(dvAttr.Value.ToLower() == pi.GetValue(obj).ToString().ToLower()) {
Console.WriteLine("Default value of {0} skipped for {1}", dvAttr.Value, pi.Name);
}
else
{
Console.WriteLine("Default value of {0} overwritten by {1} for {2}", dvAttr.Value, pi.GetValue(obj).ToString(), pi.Name);
elem.SetAttribute(pi.Name, pi.GetValue(obj).ToString());
}
}
}
}
return elem;
}
示例6: putIntoElement
public virtual void putIntoElement(XmlElement cur)
{
cur.SetAttribute("name", Name);
cur.SetAttribute("owner", Owner);
cur.SetAttribute("borrower", Borrower);
cur.SetAttribute("category", Category);
}
示例7: ApplyHashIfApplicable
private static void ApplyHashIfApplicable(XmlElement linkElement, Localization localization)
{
string target = linkElement.GetAttribute("target").ToLower();
if (target != "anchored")
{
return;
}
string href = linkElement.GetAttribute("href");
bool samePage = string.Equals(href,
HttpContext.Current.Request.Url.AbsolutePath, // TODO: should not be using HttpContext at this level
StringComparison.OrdinalIgnoreCase
);
string linkTitle = GetLinkTitle(linkElement, localization);
string fragmentId = string.Empty;
if (!string.IsNullOrEmpty(linkTitle))
{
fragmentId = '#' + linkTitle.Replace(" ", "_").ToLower();
}
linkElement.SetAttribute("href", (!samePage ? href : string.Empty) + fragmentId);
linkElement.SetAttribute("target", !samePage ? "_top" : string.Empty);
}
示例8: HandleAttributes
void HandleAttributes(XmlElement gapi_elem)
{
bool needs_array = true;
foreach (XmlAttribute attr in elem.Attributes) {
switch (attr.Name) {
case "c:type":
gapi_elem.SetAttribute ("type", attr.Value);
break;
case "fixed-size":
gapi_elem.SetAttribute ("array_len", attr.Value);
break;
case "length":
gapi_elem.SetAttribute ("length_param", attr.Value);
break;
case "name":
if (!elem.HasAttribute ("c:type"))
gapi_elem.SetAttribute ("type", SymbolTable.Lookup (attr.Value));
needs_array = false;
break;
default:
Console.WriteLine ("Unexpected attribute on array element: " + attr.Name);
break;
}
}
if (needs_array)
gapi_elem.SetAttribute ("array", "1");
}
示例9: SaveNotificationToXml
public override void SaveNotificationToXml(INotification notification, XmlElement notificationElement)
{
var n = notification as PopupNotification;
notificationElement.SetAttribute("notificationText", n.NotificationText);
notificationElement.SetAttribute("caption", n.Caption);
notificationElement.SetAttribute("icon", n.Icon.ToString());
}
示例10: SaveConditionToXml
public override void SaveConditionToXml(ICondition condition, XmlElement conditionElement)
{
var c = condition as TimeOfDayCondition;
conditionElement.SetAttribute("start", c.StartTime.ToString());
conditionElement.SetAttribute("end", c.EndTime.ToString());
conditionElement.SetAttribute("shouldBeWithin", c.ShouldBeWithin.ToString());
}
示例11: WriteToXml
public virtual void WriteToXml(XmlElement parent)
{
parent.SetAttribute("projectId", GetProject().GetPersistentID());
parent.SetAttribute("typeName", TypeName);
parent.SetAttribute("methodName", FieldName);
parent.SetAttribute("isIgnored", Explicit.ToString());
}
示例12: SaveReminderInternal
protected override void SaveReminderInternal(IReminder reminder, XmlElement reminderElement)
{
var ir = (IntervalReminder)reminder;
reminderElement.SetAttribute("fromInterval", ir.FromInterval.ToString());
reminderElement.SetAttribute("toInterval", ir.ToInterval.ToString());
}
示例13: TraceToXML
public TraceToXML(Point beginPoint, String penColor, String penWidth)
{
this.beginPoint = beginPoint;
//创建 XML 对象
xmlDocument = new XmlDocument();
//声明 XML
xmlDeclare = xmlDocument.CreateXmlDeclaration("1.0", "utf-8", null);
//创建根节点
elementRoot = xmlDocument.CreateElement("Trace");
xmlDocument.AppendChild(elementRoot);
//创建第一个节点
//创建节点 Section
elementSection = xmlDocument.CreateElement("Section");
elementSection.SetAttribute("penColor", penColor);
elementSection.SetAttribute("penWidth", penWidth);
elementRoot.AppendChild(elementSection);
//创建 Section 的子节点 Point
XmlElement elementPoint = xmlDocument.CreateElement("Point");
elementPoint.SetAttribute("time", "0");
XmlElement elementX = xmlDocument.CreateElement("X");
elementX.InnerText = beginPoint.X.ToString();
elementPoint.AppendChild(elementX);
XmlElement elementY = xmlDocument.CreateElement("Y");
elementY.InnerText = beginPoint.Y.ToString();
elementPoint.AppendChild(elementY);
elementSection.AppendChild(elementPoint);
}
示例14: NavigationProperty
internal NavigationProperty(EDMXFile parentFile, ModelEntityType modelEntityType, string name, ModelAssociationSet modelAssociationSet, XmlElement entityTypeElement, string fromRoleName, string toRoleName)
: base(parentFile)
{
_modelEntityType = modelEntityType;
_propertyElement = EDMXDocument.CreateElement("NavigationProperty", NameSpaceURIcsdl);
_propertyElement.SetAttribute("Relationship", modelAssociationSet.FullName);
if (string.IsNullOrEmpty(fromRoleName) || string.IsNullOrEmpty(toRoleName))
{
if (modelAssociationSet.FromEntityType == _modelEntityType)
{
fromRoleName = modelAssociationSet.FromRoleName;
toRoleName = modelAssociationSet.ToRoleName;
}
else
{
fromRoleName = modelAssociationSet.ToRoleName;
toRoleName = modelAssociationSet.FromRoleName;
}
}
_propertyElement.SetAttribute("FromRole", fromRoleName);
_propertyElement.SetAttribute("ToRole", toRoleName);
entityTypeElement.AppendChild(_propertyElement);
Name = name;
}
示例15: StoryStarting
public void StoryStarting(Story story)
{
_currentStoryElement = _doc.CreateElement(XmlNames.Story);
_currentStoryElement.SetAttribute(XmlNames.Id, story.Id);
_currentStoryElement.SetAttribute(XmlNames.Summary, story.Summary);
SetStatus(_currentStoryElement, StatusNames.Success);
_doc.DocumentElement.AppendChild(_currentStoryElement);
}