ProjectLocal(Func<T>)
Initializes a new instance of the ProjectLocal<T> class.
Declaration
public ProjectLocal(Func<T> initialValueFactory = null)Parameters
| Type | Name | Description |
|---|---|---|
| Func<T> | initialValueFactory | A function that creates the initial value of each project, or |
ProjectLocal(string, Func<T>)
Initializes a new instance of the ProjectLocal<T> class, whose storage is identified by a name.
Declaration
public ProjectLocal(string slotName, Func<T> initialValueFactory = null)Parameters
| Type | Name | Description |
|---|---|---|
| string | slotName | A name that identifies this value in every copy of the assembly that declares it. The caller
is responsible for its uniqueness in the process: include the full name of the declaring type and the name of the
field, for instance |
| Func<T> | initialValueFactory | A function that creates the initial value of each project, or |
Remarks
Use this constructor in an assembly that PostSharp may load more than once in a process, such as a library of aspects that each compilation loads into its own load context. Every copy of the assembly then shares one place in the storage of a project, instead of adding one more for each copy. A project sees one copy of the assembly only, so the copies never share a value.
Two ProjectLocal<T> created with the same name share their value in a project, whatever their
T, which corrupts both.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|