TypeInitializationManager Class |
Namespace: PostSharp.Sdk.AspectInfrastructure
Assembly: PostSharp.Compiler.Engine (in PostSharp.Compiler.Engine.dll) Version: 2023.0.3.0 (2023.0.3.0)
public sealed class TypeInitializationManager : IDisposable
The TypeInitializationManager type exposes the following members.
Name | Description | |
---|---|---|
Dispose | Releases all resources used by the TypeInitializationManager | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetInitializeAspectsProtectedMethod |
Gets the generated InitializeAspects protected method
for a given type.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
RegisterClient(ITypeInitializationClient, TypeInitializationClientScopes) |
Registers a client with scope Module, and only as a module initializer.
Any other scope is ignored.
| |
RegisterClient(TypeDefDeclaration, ITypeInitializationClient, TypeInitializationClientScopes) |
Registers an ITypeInitializationClient for a given TypeDefDeclaration.
| |
RegisterCloneClient | ||
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Aspects that need to be initialized should register themselves using the RegisterClient(TypeDefDeclaration, ITypeInitializationClient, TypeInitializationClientScopes) method.
An instance of this class is available on the TypeInitializationManager property of the AspectInfrastructureTask class.
The TypeInitializationManager performs the following transformations:
- For each type requiring initialization, it creates a private method (typically named ~InitializeAspects~1) and let all clients (register using RegisterClient(TypeDefDeclaration, ITypeInitializationClient, TypeInitializationClientScopes)) emit code in that method. Then, constructors are enhanced so that they invoke this method.
- It creates a protected virtual method named InitializeAspects, calling the base method (if any), then calling the private method described above. This protected method can be retrieved using GetInitializeAspectsProtectedMethod(TypeDefDeclaration).