Definition
Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml.Serialization Inheritance: System.AttributeSyntax
Summary
Specifies the local name of the XML element or attribute that a property or field is serialized as. This class cannot be inherited.Usage
Apply[XmlPropertyName] to a property or field to set its XML name. It is the counterpart of [JsonPropertyName], and it works whether the member is written as an element or as an XML attribute. On an enumeration member, it sets the name the value is written as.
Name is written as the title element.
CatalogItem with these attributes produces the following XML:
Remarks
The name overrides any naming policy, and takes precedence over the name set by XmlElementAttribute, XmlAttributeAttribute, or XmlArrayAttribute on the same member. This attribute is analogous toJsonPropertyNameAttribute in System.Text.Json.
On a member of an enumeration, the name is the text the member is written as and read from, as
JsonStringEnumMemberNameAttribute is in System.Text.Json. It replaces the C# name and is
matched exactly, while a C# name is matched without regard to case. A name cannot start or end with
white space, and the name of a FlagsAttribute member cannot contain any.
Considerations
- The name takes precedence over a name set in
[XmlElement],[XmlAttribute], or[XmlArray]on the same member, and a naming policy doesn’t convert it. - The attribute sets the local name only. To set a namespace, use the
Namespaceproperty of[XmlElement],[XmlAttribute], or[XmlArray]. - On a collection with no
[XmlArray], the name applies to each repeated item. With[XmlArray], it names the wrapper element. - Two members of one type can’t have the same attribute name, and two element members can’t have the same element name in the same namespace. The serializer throws an
InvalidOperationExceptionthe first time it uses such a type. - On an enumeration member, the attribute sets the name the value is written as, such as
[XmlPropertyName("next-day")]onNextDay. When reading, that name is matched exactly, while the other member names are matched in any case. See Enumeration values.
Constructors
.ctor
Initializes a new instance of the XmlPropertyNameAttribute class with the specified name.Syntax
Parameters
Exceptions
.ctor Inherited
Inherited from
System.AttributeSyntax
.ctor Inherited
Inherited from
objectSyntax
Properties
Name
Gets the local name of the XML element or attribute.Syntax
Property Value
Type:string
The local name of the XML element or attribute.
TypeId Inherited Virtual
Inherited from
System.AttributeSyntax
Property Value
Type:object
Methods
Equals Override
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttribute Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute?
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetCustomAttributes Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:System.Attribute[]
GetHashCode Override
Inherited from
System.AttributeSyntax
Returns
Type:int
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
IsDefaultAttribute Inherited Virtual
Inherited from
System.AttributeSyntax
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
IsDefined Inherited
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
Match Inherited Virtual
Inherited from
System.AttributeSyntax
Parameters
Returns
Type:bool
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
ToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Related APIs
- CloudNimble.Text.Xml.XmlNamingPolicy
- CloudNimble.Text.Xml.Serialization.XmlElementAttribute
- CloudNimble.Text.Xml.Serialization.XmlAttributeAttribute
- CloudNimble.Text.Xml.Serialization.XmlRootAttribute
- CloudNimble.Text.Xml.Serialization.XmlPropertyOrderAttribute