Exemple #1
0
 protected bool MoveToAttribute(uint?index)
 {
     if (_parser.EventCode != ResXMLParser.XmlParserEventCode.START_TAG)
     {
         return(false);
     }
     _attributeIndex = index;
     if (index == null)
     {
         string ns = _parser.ElementNamespace;
         SetState(nodeType: XmlNodeType.Element,
                  prefix: LookupPrefix(ns),
                  localName: _parser.ElementName,
                  namespaceUri: ns);
     }
     else
     {
         ResXMLParser.AttributeInfo attr = _parser.GetAttribute(index);
         string ns = attr.Namespace;
         SetState(
             nodeType: XmlNodeType.Attribute,
             prefix: LookupPrefix(ns),
             localName: attr.Name,
             namespaceUri: ns,
             value: attr.ValueStringID != null ? attr.ValueString : FormatValue(attr.TypedValue));
     }
     return(true);
 }
Exemple #2
0
 /// <summary>
 /// Gets the value of the attribute with the specified index.
 /// </summary>
 /// <returns>
 /// The value of the specified attribute. This method does not move the reader.
 /// </returns>
 /// <param name="i">The index of the attribute. The index is zero-based. (The first attribute has index 0.) </param>
 /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="i"/> is out of range. It must be non-negative and less than the size of the attribute collection.</exception>
 public override string GetAttribute(int i)
 {
     if (_parser.EventCode != ResXMLParser.XmlParserEventCode.START_TAG)
     {
         return(null);
     }
     ResXMLParser.AttributeInfo attr = _parser.GetAttribute(i < 0 ? null : (uint?)i);
     if (attr == null)
     {
         throw new ArgumentOutOfRangeException("i");
     }
     if (attr.ValueStringID != null)
     {
         return(attr.ValueString);
     }
     return(FormatValue(attr.TypedValue));
 }