OptionalAttribute Class

Marks a constructor parameter to be bound to an XML element that occurs once or not at all.

C#
[AttributeUsage(System.AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
public sealed class OptionalAttribute : Attribute
Inheritance
OptionalAttribute
Attributes

Remarks

If the Oxbinder<T> finds the XML child element, it creates the object bound to the element, and then populates the annotated parameter with the object.

This annotation must mark a constructor parameter. The class containing this constructor must be annotated with ForElementAttribute.

The parameter must be of type T? or BindResult<T>?, where T is a class annotated with ForElementAttribute. If no matching child element is found, null is provided.

After a parameter with OptionalAttribute, you cannot specify another parameter for the same element name with RequiredAttribute or MultipleAttribute.

Properties

TypeId (Inherited from Attribute)

Methods

Equals(object) (Inherited from Attribute)
GetHashCode() (Inherited from Attribute)
IsDefaultAttribute() (Inherited from Attribute)
Match(object) (Inherited from Attribute)
GetType() (Inherited from object)
MemberwiseClone() (Inherited from object)
ToString() (Inherited from object)

See Also