Open sandboxFocus

Class OnInstanceConstructedAdvice

Custom attribute that, when applied to a method of an aspect, specifies that this method should be executed after the last instance constructor of the target class of the aspect has completed execution. That is, this method is invoked when the target object is fully constructed. This custom attribute can be applied only on methods that have return type void.

Inheritance
OnInstanceConstructedAdvice
Namespace: PostSharp.Aspects.Advices
Assembly: PostSharp.dll
Syntax
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class OnInstanceConstructedAdvice : Advice
Remarks

The target object is fully constructed when all its constructors complete execution, including constructors of subclasses. For example, if you apply this advice to type A, and class B extends class A, then if you create a new instance of B, the method will be invoked only after B's constructor ends.

The parameters of the method must be bound by a custom attribute derived from AdviceParameterAttribute. Their target is the target type of the aspect: for instance, ThisAttribute binds the object and DeclarationNameAttribute the name of the type. ArgumentAttribute, ReturnValueAttribute, LocationValueAttribute and FlowBehaviorAttribute cannot be used.

Constructors

Name Description
OnInstanceConstructedAdvice()