Open sandboxFocus

Class ChildAttribute

Custom attribute that, when applied to a field or automatic property, specifies that the object assigned to this field or property is a child of the instance of the declaring type.

Inheritance
ChildAttribute
Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Aggregation.dll
Syntax
public sealed class ChildAttribute : MemberRelationshipAttribute, IValidableAnnotation
Remarks

When the field or property holds a collection, assign an advisable collection, such as AdvisableCollection<T>, or an immutable collection. By default, a collection is a parent surrogate: its items are children of the declaring instance, and the collection itself is skipped by VisitChildren(ChildVisitor, ChildVisitorOptions, object) (see IsParentSurrogate). To make the items of the collection references, set ItemsRelationship to Reference. The collection stays a parent surrogate.

Constructors

Name Description
ChildAttribute()

Initializes a new instance of the ChildAttribute class.

Properties

Name Description
DisableBehaviorPropagation

Gets or sets a value indicating whether the behaviors applied to the declaring type of the target field should be applied to the object assigned to this field. The default value of this property is false, which means that behaviors such as Recordable or threading models will be applied to children. If this is not possible, an exception occurs at build time or at run time. When it is set to true, behaviors will not be propagated. When applied to a field of collection type, the value applies to collection items.

DisableBuildTimeValidation

Gets or sets a value indicating whether the type of the target field or property should be validated at build time against the rules of aspects that rely on the Aggregatable model, such as the Recordable aspect or the threading model aspects. If this property is set to true, validation will be performed at run time only.

IsParentSurrogate

Gets or sets a value indicating whether the value assigned to the field or property is a parent surrogate. The Parent property of children of a parent surrogate is set to the parent of the parent surrogate, instead of to the field itself.

ItemsRelationship

Gets or sets the kind of relationship between items.

See Also