Aspect that, when applied to an event, prevents the target event from holding a strong reference to event handlers. Therefore, the aspect prevents the event to prevent clients to be garbage collected.
Inheritance
WeakEventAttribute
Implements
Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model.dll
Syntax
[LinesOfCodeAvoided(6)]
[Serializer(typeof(WeakEventAttribute.Serializer))]
public sealed class WeakEventAttribute : EventInterceptionAspect, IEventLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, IEventInterceptionAspect, IEventLevelAspect, IInstanceScopedAspect, IAspectRemarks
Event clients do not need to keep a strong reference to the delegates passed to a weak event. The WeakEventAttribute implementation will keep delegate instances alive as long as the event source (i.e. whatever object the Target property points to) is alive, but no longer.
Constructors
| Name | Description |
|---|---|
| WeakEventAttribute() | Initializes a new WeakEventAttribute. |
| WeakEventAttribute(PortableFormatterConstructorContext) |