本文整理汇总了C#中System.Xml.XmlAttribute类的典型用法代码示例。如果您正苦于以下问题:C# XmlAttribute类的具体用法?C# XmlAttribute怎么用?C# XmlAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlAttribute类属于System.Xml命名空间,在下文中一共展示了XmlAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTypeByNode
private static PhoneNumberElementType GetTypeByNode(XmlAttribute node)
{
var str = node.InnerText;
switch (str)
{
case "international-prefix":
return PhoneNumberElementType.InternationalPrefix;
case "country-prefix":
return PhoneNumberElementType.CountryPrefix;
case "national-prefix":
return PhoneNumberElementType.NationalPrefix;
case "unknown-national-prefix":
return PhoneNumberElementType.UnknownNationalPrefix;
case "national-code":
return PhoneNumberElementType.NationalCode;
case "area-code":
return PhoneNumberElementType.AreaCode;
case "local-number":
return PhoneNumberElementType.LocalNumber;
default:
throw new MalformedXMLException (
"The XML Received from Time and Date did not include an object name which complies with an AstronomyObjectType enum: " +
str
);
}
}
示例2: ValidateXmlAnyAttributes
/// <summary>
/// Validates the XML any attributes.
/// </summary>
/// <param name="anyAttributes">Any attributes.</param>
public void ValidateXmlAnyAttributes(XmlAttribute[] anyAttributes)
{
if (anyAttributes == null)
{
throw new ArgumentNullException("anyAttributes");
}
if (anyAttributes.Length == 0)
{
return;
}
foreach (var attr in anyAttributes)
{
if (!Saml20Utils.ValidateRequiredString(attr.Prefix))
{
throw new Saml20FormatException("Attribute extension xml attributes MUST BE namespace qualified");
}
foreach (var samlns in Saml20Constants.SamlNamespaces)
{
if (attr.NamespaceURI == samlns)
{
throw new Saml20FormatException("Attribute extension xml attributes MUST NOT use a namespace reserved by SAML");
}
}
}
}
示例3: Serialize
public void Serialize(XmlElement node)
{
if (ShouldIgnore(node))
return;
Serialize(BEGIN_ELEMENT);
Serialize(node.NamespaceURI);
Serialize(node.LocalName);
var attrs = new XmlAttribute[node.Attributes.Count];
node.Attributes.CopyTo(attrs, 0);
Array.Sort(attrs, new AttributeComparer());
foreach (var attr in attrs) {
Serialize(attr);
}
Serialize(END_ATTRIBUTES);
foreach (XmlNode child in node.ChildNodes) {
if (child is XmlElement) {
Serialize(child as XmlElement);
} else {
Serialize(child as XmlCharacterData);
}
}
Serialize(END_ELEMENT);
}
示例4: InitAtrrib
protected override void InitAtrrib(XmlAttribute Attr)
{
if(Attr.Name == "digits")
Digits = byte.Parse(Attr.Value);
else if(Attr.Name == "magnitude")
Magnitude = short.Parse(Attr.Value);
}
示例5: Exception
void IHasAttribute.InitAtrribute(XmlAttribute Attr)
{
switch(Attr.Name)
{
case "mips_generate":
MipGenerate = bool.Parse(Attr.Value);
break;
case "array_index":
ArrayIndex = uint.Parse(Attr.Value);
break;
case "mip_index":
MipIndex = uint.Parse(Attr.Value);
break;
case "depth":
Depth = uint.Parse(Attr.Value);
break;
case "face":
Face = (CubeFace)Enum.Parse(typeof(CubeFace),Attr.Value);
break;
default:
throw new Exception("Invalid Atrribute");
}
}
示例6: ParseAttribute
/// <summary>
/// Processes an attribute for the Compiler.
/// </summary>
/// <param name="sourceLineNumbers">Source line number for the parent element.</param>
/// <param name="parentElement">Parent element of element to process.</param>
/// <param name="attribute">Attribute to process.</param>
/// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
public override void ParseAttribute(SourceLineNumberCollection sourceLineNumbers, XmlElement parentElement, XmlAttribute attribute, Dictionary<string, string> contextValues)
{
switch (parentElement.LocalName)
{
case "ExePackage":
case "MsiPackage":
case "MspPackage":
case "MsuPackage":
string packageId;
if (!contextValues.TryGetValue("PackageId", out packageId) || String.IsNullOrEmpty(packageId))
{
this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, parentElement.LocalName, "Id", attribute.LocalName));
}
else
{
switch (attribute.LocalName)
{
case "PrereqSupportPackage":
if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute))
{
Row row = this.Core.CreateRow(sourceLineNumbers, "MbaPrerequisiteSupportPackage");
row[0] = packageId;
}
break;
default:
this.Core.UnexpectedAttribute(sourceLineNumbers, attribute);
break;
}
}
break;
case "Variable":
// at the time the extension attribute is parsed, the compiler might not yet have
// parsed the Name attribute, so we need to get it directly from the parent element.
string variableName = parentElement.GetAttribute("Name");
if (String.IsNullOrEmpty(variableName))
{
this.Core.OnMessage(WixErrors.ExpectedParentWithAttribute(sourceLineNumbers, "Variable", "Overridable", "Name"));
}
else
{
switch (attribute.LocalName)
{
case "Overridable":
if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute))
{
Row row = this.Core.CreateRow(sourceLineNumbers, "WixStdbaOverridableVariable");
row[0] = variableName;
}
break;
default:
this.Core.UnexpectedAttribute(sourceLineNumbers, attribute);
break;
}
}
break;
default:
this.Core.UnexpectedAttribute(sourceLineNumbers, attribute);
break;
}
}
示例7: GetValueAsString
public static string GetValueAsString(XmlAttribute attribute, string defaultValue)
{
if (attribute == null)
return defaultValue;
return Mask.EmptyString(attribute.Value, defaultValue);
}
示例8: GetXmlAttributeAsString
private string GetXmlAttributeAsString(XmlAttribute attribute) {
if (attribute == null) return "";
return attribute.Value.Trim();
}
示例9: ConditionEvaluationState
internal ConditionEvaluationState(XmlAttribute conditionAttribute, Expander expanderToUse, Hashtable conditionedPropertiesInProject, string parsedCondition)
{
this.conditionAttribute = conditionAttribute;
this.expanderToUse = expanderToUse;
this.conditionedPropertiesInProject = conditionedPropertiesInProject;
this.parsedCondition = parsedCondition;
}
示例10: ExecuteCore
protected override void ExecuteCore(XmlAttribute attribute)
{
var data = string.Format("{0}=\"{1}\"", attribute.Name, attribute.Value);
var section = attribute.OwnerDocument.CreateCDataSection(data);
attribute.OwnerElement.PrependChild(section);
attribute.OwnerElement.Attributes.Remove(attribute);
}
示例11: ParseAttribute
/// <summary>
/// Processes an attribute for the Compiler.
/// </summary>
/// <param name="sourceLineNumbers">Source line number for the parent element.</param>
/// <param name="parentElement">Parent element of element to process.</param>
/// <param name="attribute">Attribute to process.</param>
/// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
public override void ParseAttribute(SourceLineNumberCollection sourceLineNumbers, XmlElement parentElement, XmlAttribute attribute, Dictionary<string, string> contextValues)
{
switch (parentElement.LocalName)
{
case "Extension":
// at the time the IsRichSavedGame extension attribute is parsed, the compiler
// might not yet have parsed the Id attribute, so we need to get it directly
// from the parent element and put it into the contextValues dictionary.
string extensionId = parentElement.GetAttribute("Id");
if (String.IsNullOrEmpty(extensionId))
{
this.Core.OnMessage(WixErrors.ExpectedParentWithAttribute(sourceLineNumbers, "Extension", "IsRichSavedGame", "Id"));
}
else
{
contextValues["ExtensionId"] = extensionId;
switch (attribute.LocalName)
{
case "IsRichSavedGame":
if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attribute))
{
this.ProcessIsRichSavedGameAttribute(sourceLineNumbers, contextValues);
}
break;
default:
this.Core.UnexpectedAttribute(sourceLineNumbers, attribute);
break;
}
}
break;
default:
this.Core.UnexpectedElement(parentElement, parentElement);
break;
}
}
示例12: GetModifiedDateTime
private static DateTime GetModifiedDateTime(DateTime dateTime, XmlAttribute attr, int value)
{
switch (attr.Name.ToLower(CultureInfo.InvariantCulture))
{
case "year":
case "addyear":
dateTime = dateTime.AddYears(value);
break;
case "month":
case "addmonth":
dateTime = dateTime.AddMonths(value);
break;
case "week":
case "addweek":
dateTime = dateTime.AddDays(value * 7);
break;
case "day":
case "adday":
dateTime = dateTime.AddDays(value);
break;
case "hour":
case "addhour":
dateTime = dateTime.AddHours(value);
break;
case "min":
case "addmin":
dateTime = dateTime.AddMinutes(value);
break;
case "sec":
case "addsec":
dateTime = dateTime.AddSeconds(value);
break;
}
return dateTime;
}
示例13: XmlAttributeEventArgs
internal XmlAttributeEventArgs(XmlAttribute attr, int lineNum, int linePos, object source)
{
this.attr = attr;
this.lineNumber = lineNum;
this.linePosition = linePos;
this.obj = source;
}
示例14: FilterNull
// Methods
private static string FilterNull(XmlAttribute strValue)
{
if (strValue != null)
{
return strValue.Value.ToString();
}
return "";
}
示例15: When
/// <summary>
/// Constructor for the When block. Parses the contents of the When block (property
/// groups, item groups, and nested chooses) and stores them.
/// </summary>
/// <remarks>
/// </remarks>
/// <owner>DavidLe</owner>
/// <param name="parentProject"></param>
/// <param name="parentGroupingCollection"></param>
/// <param name="whenElement"></param>
/// <param name="importedFromAnotherProject"></param>
/// <param name="options"></param>
/// <param name="nestingDepth">stack overflow guard</param>
internal When(
Project parentProject,
GroupingCollection parentGroupingCollection,
XmlElement whenElement,
bool importedFromAnotherProject,
Options options,
int nestingDepth
)
{
// Make sure the <When> node has been given to us.
error.VerifyThrow(whenElement != null, "Need valid (non-null) <When> element.");
// Make sure this really is the <When> node.
error.VerifyThrow(whenElement.Name == XMakeElements.when || whenElement.Name == XMakeElements.otherwise,
"Expected <{0}> or <{1}> element; received <{2}> element.",
XMakeElements.when, XMakeElements.otherwise, whenElement.Name);
this.propertyAndItemLists = new GroupingCollection(parentGroupingCollection);
this.parentProject = parentProject;
string elementName = ((options == Options.ProcessWhen) ? XMakeElements.when : XMakeElements.otherwise);
if (options == Options.ProcessWhen)
{
conditionAttribute = ProjectXmlUtilities.GetConditionAttribute(whenElement, /*verify sole attribute*/ true);
ProjectErrorUtilities.VerifyThrowInvalidProject(conditionAttribute != null, whenElement, "MissingCondition", XMakeElements.when);
}
else
{
ProjectXmlUtilities.VerifyThrowProjectNoAttributes(whenElement);
}
ProcessWhenChildren(whenElement, parentProject, importedFromAnotherProject, nestingDepth);
}