Open sandboxFocus

Class InitializeAspectInstanceAdvice

Custom attribute that, when applied to a method of an aspect class, specifies that this method should be invoked whenever the aspect instance needs to be initialized. The target method must have a void return value and have a single parameter of type AspectInitializationReason. This method is equivalent to RuntimeInitializeInstance().

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

Unlike RuntimeInitializeInstance(), the advice method receives the reason of the initialization: a constructor, a call of MemberwiseClone, deserialization, or a manual call of the InitializeAspects method.

To run logic after all the aspects applied to the same target have been initialized, use OnAspectsInitializedAdvice.

The aspect must be applied to a type or to a member of a type. For a member, the advice is registered on the declaring type of the member. In an aspect applied to an assembly, such as an AssemblyLevelAspect, the advice causes the error LA0088.

Constructors

Name Description
InitializeAspectInstanceAdvice()

See Also