PostSharpAPI ReferencePost­Sharp.​Patterns.​ModelDisposable­Attribute
Open sandboxFocus

DisposableAttribute Class

Custom attribute that, when applied to a class, implements the IDisposable in such a way that the Dispose() method executes the Dispose() method for all children objects that also implement the IDisposable interface.

Namespace: PostSharp.Patterns.Model
Assembly: PostSharp.Patterns.Model.dll
Syntax
[IntroduceInterface]
[MulticastAttributeUsage]
[HasConstraint]
[Serializer]
public sealed class DisposableAttribute : AggregatableClientAttribute, ITypeLevelAspect, ITypeLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, ICloneAwareAspect, IInstanceScopedAspect, IAspectProvider, IService, IAdviceProvider, IAspect

Constructors

Name Description
DisposableAttribute()
DisposableAttribute(PortableFormatterConstructorContext)

Fields

Name Description
BaseDisposeMethod
DisposeMethod

Properties

Name Description
ThrowObjectDisposedException

Determines whether an ObjectDisposedException should be thrown when an attempt is made to access an object that has already been disposed.

Methods

Name Description
Advise(Object)

Injects the advice into the child object.

Dispose()
Dispose(Boolean)
IsEligibleChild(Object, ChildInfo)

Determines if an object is eligible to be a child of the target instance of the current aspect.

OnAdviseChildFailed(Object)

Method invoked when a child is assigned to a parent and the advices of the parent cannot be added to the child. Implementations can choose to throw an exception (thread-aware attributes do this) or ignore the situation (DisposableAttribute does this).

OnMethodEntry(MethodExecutionArgs)