Class GetOnceNamed<TResult>
[InternalApi_DoNotUse_MayChangeWithoutNotice("Experimental")]
public class GetOnceNamed<TResult>
Type Parameters
TResult
- Inheritance
-
objectGetOnceNamed<TResult>
Constructors
GetOnceNamed()
Construct an empty GetOnceNamed object for use later on.
In case you're wondering why we can't pass the generator in on the constructor:
Reason is that in most cases we need real objects in the generator function,
which doesn't work in a static
context.
This means that if the = new GetOnce() is run on the private property
(which is the most common case) most generators can't be added.
public GetOnceNamed()
Fields
Cache
public IDictionary<string, TResult> Cache
Field Value
- IDictionary<string, TResult>
Methods
Get(string, Func<TResult>)
Get the value. If not yet retrieved, use the generator function (but only once).
public TResult Get(string name, Func<TResult> generator)
Parameters
name
stringName of named instance, to use for caching
generator
Func<TResult>Function which will generate the value on first use.
Returns
- TResult
IsValueCreated(string)
public bool IsValueCreated(string name)
Parameters
name
string
Returns
Reset()
public void Reset()
Reset(string)
public void Reset(string name)
Parameters
name
string