8using System.Collections.Generic;
16 public struct XmlAttribute
21 public string Name {
get;
private set; }
25 public string Value {
get;
private set; }
33 public string Prefix {
get;
private set; }
42 internal XmlAttribute(
string name,
string value,
string prefix =
"")
47 HasPrefix = !
string.IsNullOrEmpty(prefix);
57 public static XmlAttribute
CreateAttribute(
string name,
string value,
string prefix =
"")
59 return new XmlAttribute(name, value, prefix);
70 return new XmlAttribute(name,
"", prefix);
79 public static XmlAttribute?
FindAttribute(
string name, HashSet<XmlAttribute> attributes)
81 if (attributes ==
null || attributes.Count == 0)
85 if (!attributes.Any(a => a.Name == name))
89 return attributes.Where(a => a.Name == name).FirstOrDefault();
97 public override bool Equals(
object obj)
99 return obj is XmlAttribute attribute &&
100 Name == attribute.Name &&
101 Value == attribute.Value &&
102 Prefix == attribute.Prefix;
113 int hashCode = 27885120;
114 hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(
Name);
115 hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(
Value);
116 hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(
Prefix);
Struct representing an internally used XML attribute.
string Prefix
Prefix of the attribute. If not defined, the prefix will be an empty string.
override bool Equals(object obj)
Returns whether two instances are the same.
bool HasPrefix
True if a prefix for the attribute was defined.
static ? XmlAttribute FindAttribute(string name, HashSet< XmlAttribute > attributes)
Method to find an attribute in a given list by attribute name. It is assumed that there are no duplic...
override int GetHashCode()
Gets the hash code of the attribute.
static XmlAttribute CreateAttribute(string name, string value, string prefix="")
Method to create an attribute instance.
static XmlAttribute CreateEmptyAttribute(string name, string prefix="")
Method to create an empty attribute instance.
string Name
Name of the attribute (without prefix).
string Value
Attribute value as string.