當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。