Skip to main content

Definition

Assembly: CloudNimble.XmlEssentials.dll Namespace: CloudNimble.Text.Xml.Serialization Inheritance: System.Attribute

Syntax

Summary

Prevents a property or field from being serialized or deserialized, or from being written when a condition is met. This class cannot be inherited.

Usage

Apply [XmlIgnore] to a property or field to keep it out of the XML. It is the counterpart of [JsonIgnore]. With no arguments, the member is never written and never read.
The code produces the following output:
Set Condition to leave the member out only when it has no value:
The code produces the following output:
View the complete sample on GitHub

Considerations

  • With the default condition, Always, the member isn’t part of the type’s XML mapping at all. An element for it in incoming XML is an unmapped member: skipped by default, and an error when UnmappedMemberHandling is Disallow.
  • With WhenWritingNull, WhenWritingDefault, or WhenWriting, the member is still read when the XML has it. Those conditions affect writing only. WhenReading is the other way round: the member is written and never read.
  • The attribute overrides XmlSerializerOptions.DefaultIgnoreCondition for the member. [XmlIgnore(Condition = XmlIgnoreCondition.Never)] keeps a member in every document when the option would leave it out.
  • Ignoring a positional record property with [property: XmlIgnore] leaves its constructor parameter with no member to bind to, and the record can no longer be deserialized.
  • To leave out every null member at once, set DefaultIgnoreCondition on the options.

Constructors

.ctor

Syntax

.ctor Inherited

Inherited from System.Attribute

Syntax

.ctor Inherited

Inherited from object

Syntax

Properties

Condition

Gets or sets the condition that must be met before the member is ignored.

Syntax

Property Value

Type: CloudNimble.Text.Xml.Serialization.XmlIgnoreCondition One of the enumeration values that specifies when the member is ignored. The default is XmlIgnoreCondition.Always.

Remarks

The value takes precedence over XmlSerializerOptions.DefaultIgnoreCondition for the member.

TypeId Inherited Virtual

Inherited from System.Attribute

Syntax

Property Value

Type: object

Methods

Equals Override

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttribute Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute?

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetCustomAttributes Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: System.Attribute[]

GetHashCode Override

Inherited from System.Attribute

Syntax

Returns

Type: int

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

IsDefaultAttribute Inherited Virtual

Inherited from System.Attribute

Syntax

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

IsDefined Inherited

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

Match Inherited Virtual

Inherited from System.Attribute

Syntax

Parameters

Returns

Type: bool

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?
  • CloudNimble.Text.Xml.Serialization.XmlIgnoreCondition
  • CloudNimble.Text.Xml.Serialization.XmlIncludeAttribute
  • CloudNimble.Text.Xml.Serialization.XmlUnmappedMemberHandling
  • CloudNimble.Text.Xml.XmlSerializerOptions