Skip to main content

Definition

Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml.Serialization

Syntax

Summary

Represents a value together with the name of the element it is written under. This class cannot be inherited.

Usage

An XmlNamedValue is a value together with the name of the element it is written under. Use it for a member that has a choice of elements, set with several [XmlElement<T>] attributes, when two of the elements hold the same type. The type of the value can’t say which element it belongs to, so the value carries the element’s name instead.
The code produces the following output:
Declare the member as XmlNamedValue for one value, or as a collection of it for a sequence. Name must be the name of one of the member’s elements, and Value must be of the type that element holds; anything else throws a NotSupportedException when it is written. A Value that is null is written as an element marked xsi:nil="true". Set Namespace only when two of the member’s elements have one local name in two namespaces. A value that was read has the namespace its element was declared with. See When two elements hold the same type and the polymorphism sample.

Remarks

A member that carries more than one XmlElementAttribute1` holds a choice of elements, and a value is written under the element of its type. When two of the elements hold the same type, the type does not say which element a value is. Declare the member as XmlNamedValue, or as a collection of it, and each value says which element it is by name. XmlNamedValue.Name must be the name of one of the member’s elements, and XmlNamedValue.Value must be of the type that element holds. A value that is null is written as an element marked xsi:nil.

Examples

Constructors

.ctor

Initializes a new instance of the XmlNamedValue class with no name and no value.

Syntax

.ctor

Initializes a new instance of the XmlNamedValue class with the specified element name and value.

Syntax

Parameters

Exceptions

.ctor Inherited

Inherited from object

Syntax

Properties

Name

Gets or sets the local name of the element.

Syntax

Property Value

Type: string The local name of the element the value is written under. The default is an empty string.

Namespace

Gets or sets the namespace URI of the element.

Syntax

Property Value

Type: string? The namespace URI the member gives the element, or null to find the element by its local name alone. The default is null.

Remarks

Set it when two elements of the member have one local name in two namespaces. A value that was read has the namespace its element was declared with.

Value

Gets or sets the value of the element.

Syntax

Property Value

Type: object? The value, of the type the element holds, or null. The default is null.

Methods

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?