We can simplify API of LazyReference<T> by using [CallerMemberName] attribute:
public sealed class LazyReference<T>
{
public T GetValue(object parent, [CallerMemberName] string referenceName = null);
}
And we can write
private LazyReference<Parent> _parentLazy = new LazyReference<Parent>();
public Parent Parent
{
get => _parentLazy.GetValue(this);
set => _parentLazy.SetValue(value);
}
instead of
get => _parentLazy.GetValue(this, nameof(Parent));
We can simplify API of
LazyReference<T>
by using[CallerMemberName]
attribute:And we can write
instead of