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


C# Xml.XmlAttribute类代码示例

本文整理汇总了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
         );
     }
 }
开发者ID:adny,项目名称:libtad-net,代码行数:26,代码来源:Composition.cs

示例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");
                    }
                }
            }
        }
开发者ID:jbparker,项目名称:SAML2,代码行数:32,代码来源:Saml20XmlAnyAttributeValidator.cs

示例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);
        }
开发者ID:ben-biddington,项目名称:Brick,代码行数:30,代码来源:AdobeXmlSerializer.cs

示例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);
 }
开发者ID:miquik,项目名称:leviatan-game,代码行数:7,代码来源:float_array.cs

示例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");
            }
        }
开发者ID:miquik,项目名称:leviatan-game,代码行数:28,代码来源:init_from.cs

示例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;
     }
 }
开发者ID:zooba,项目名称:wix3,代码行数:67,代码来源:BalCompiler.cs

示例7: GetValueAsString

        public static string GetValueAsString(XmlAttribute attribute, string defaultValue)
        {
            if (attribute == null)
                return defaultValue;

            return Mask.EmptyString(attribute.Value, defaultValue);
        }
开发者ID:ThePublicTheater,项目名称:NYSF,代码行数:7,代码来源:ConfigurationSectionHelper.cs

示例8: GetXmlAttributeAsString

        private string GetXmlAttributeAsString(XmlAttribute attribute) {

            if (attribute == null) return "";

            return attribute.Value.Trim();

        }
开发者ID:Jeavon,项目名称:Umbraco-CMS,代码行数:7,代码来源:helpRedirect.aspx.cs

示例9: ConditionEvaluationState

 internal ConditionEvaluationState(XmlAttribute conditionAttribute, Expander expanderToUse, Hashtable conditionedPropertiesInProject, string parsedCondition)
 {
     this.conditionAttribute = conditionAttribute;
     this.expanderToUse = expanderToUse;
     this.conditionedPropertiesInProject = conditionedPropertiesInProject;
     this.parsedCondition = parsedCondition;
 }
开发者ID:nikson,项目名称:msbuild,代码行数:7,代码来源:ConditionEvaluationState.cs

示例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);
 }
开发者ID:rh,项目名称:mix,代码行数:7,代码来源:ConvertToCdataSection.cs

示例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;
     }
 }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:42,代码来源:GamingCompiler.cs

示例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;
 }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:35,代码来源:DateTimeParser.cs

示例13: XmlAttributeEventArgs

		internal XmlAttributeEventArgs(XmlAttribute attr, int lineNum, int linePos, object source)
		{
			this.attr		= attr;
			this.lineNumber = lineNum;
			this.linePosition = linePos;
			this.obj		= source;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:XmlAttributeEventArgs.cs

示例14: FilterNull

 // Methods
 private static string FilterNull(XmlAttribute strValue)
 {
     if (strValue != null)
     {
         return strValue.Value.ToString();
     }
     return "";
 }
开发者ID:habins,项目名称:WebDS,代码行数:9,代码来源:FactoryDef.cs

示例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);

        }
开发者ID:nikson,项目名称:msbuild,代码行数:48,代码来源:When.cs


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