OnAppliedDecorationAttribute Class
System.Runtime.Serialization
Summary
Specifies that a custom attribute can be applied to members that are serialized by the DataContractSerializer.
Remarks
This attribute is used to control which custom attributes can be applied to members during serialization and deserialization. It ensures that only attributes explicitly marked as serializable by the DataContractSerializer are processed, preventing unexpected behavior or errors.
Key scenarios where this attribute is relevant:
- Defining custom serialization behaviors.
- Extending the functionality of the DataContractSerializer with metadata.
- Ensuring interoperability with other systems by controlling the scope of applied attributes.
Syntax
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = true)]
public sealed class OnAppliedDecorationAttribute : Attribute
Constructors
-
OnAppliedDecorationAttribute()
Initializes a new instance of the
OnAppliedDecorationAttributeclass.
Properties
-
Type[] AllowedCustomAttributes
Gets the array of custom attribute types that are allowed to be applied to the decorated member.
Example:
// Assuming CustomAttribute1 and CustomAttribute2 are defined elsewhere [OnAppliedDecoration(AllowedCustomAttributes = new Type[] { typeof(CustomAttribute1), typeof(CustomAttribute2) })] public class MySerializableClass { ... }