Custom attribute that, when applied to a class, enables instances of this class to be involved in a parent-child relationship.
Inheritance
Implements
Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Aggregation.dll
Syntax
[IntroduceInterface(typeof(IAttachable), OverrideAction = InterfaceOverrideAction.Ignore, AncestorOverrideAction = InterfaceOverrideAction.Ignore, LinesOfCodeAvoided = 0)]
[MulticastAttributeUsage(MulticastTargets.Class, TargetTypeAttributes = MulticastAttributes.UserGenerated)]
[AspectTypeDependency(AspectDependencyAction.Conflict, typeof(AggregatableAttribute))]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.After, "Tracing")]
[AspectRoleDependency(AspectDependencyAction.Order, AspectDependencyPosition.Before, "Validation")]
[Serializer(typeof(AggregatableAttribute.Serializer))]
public sealed class AggregatableAttribute : InstanceLevelAspect, ITypeLevelAspect, ITypeLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, ICloneAwareAspect, IInstanceScopedAspect, IAttachable, IAggregatable, IAdviceProvider, IAspectProvider, IAspect, IService, IDeserializationCallbackRemarks
This aspect implements the IAggregatable interface, which exposes members such as VisitChildren(ChildVisitor, ChildVisitorOptions, object) and Parent.
The AggregatableAttribute aspect is implicitly used by several other aspects, including all threading models.
When a class has the AggregatableAttribute aspect, its reference-type fields and automatic properties must be annotated with one of the following attributes: ChildAttribute, ReferenceAttribute or ParentAttribute. A field that cannot carry a custom attribute, such as a field generated by a designer, can instead be classified by a FieldRule registered with the RegisterFieldRuleAttribute custom attribute.
For the items of a child collection to become children of the parent, assign an advisable collection, such as AdvisableCollection<T>, or an immutable collection to the child field or property. Standard .NET collections cannot notify the parent when items are added or removed.
Target classes can customize the AggregatableAttribute aspect by implementing one or more of the members documented in the PostSharp.Patterns.Model.AggregatableAttributeTargetClass class.
Constructors
| Name | Description |
|---|---|
| AggregatableAttribute() | Initializes a new instance of the AggregatableAttribute class. |
| AggregatableAttribute(PortableFormatterConstructorContext) |
Properties
| Name | Description |
|---|---|
| ChildrenFields | Gets, at build time, the list of child fields together with their ChildInfo. |
| DefaultItemRelationship | Gets or sets the default kind of relationship for collection items. |
| DefaultMemberRelationship | Gets or sets the default kind of relationship of fields and automatic properties. |
| IsParentSurrogate | Gets or sets a value indicating whether instances of the target class of this custom attribute are parent surrogates. |
| IsParentSurrogateSpecified | Gets a value indicating whether the IsParentSurrogate property has been set. |