PropertyOrderAttribute Class
Definition
- Namespace
- Bodu.Text.Serialization
- Assembly
- Bodu.Text.Serialization.dll
- Package
- Bodu.Text.Serialization 1.0.0
Specifies the relative order in which a property or field is written, allowing the order members are emitted to the writer to differ from the order in which they are declared.
[AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class PropertyOrderAttribute : SerializationAttribute
- Inheritance
-
PropertyOrderAttribute
- Attributes
-
System.AttributeUsageAttribute
- Inherited Members
- Extension Methods
Examples
public sealed class Manifest
{
[PropertyOrder(2)]
public string Name { get; set; } = "demo";
[PropertyOrder(1)]
public int Version { get; set; } = 3;
}
// Version is presented to the writer before Name.
Remarks
Members are written in ascending Order. Members without the attribute take the default order of zero and otherwise keep their declaration order. When the target format re-sorts entries into a canonical order, this order governs the sequence in which members are presented to the writer rather than the final on-the-wire order.
Constructors
PropertyOrderAttribute(int)
Initializes a new instance of the PropertyOrderAttribute class.
public PropertyOrderAttribute(int order)
Parameters
orderintThe relative write order of the member.
Properties
Order
Gets the relative write order of the member.
public int Order { get; }
Property Value
- int
The order value; members are written in ascending order.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |