Assuming the following singleton declaration for a sealed class with a private constructor:
private static readonly Lazy<MyClass> _singleton = new Lazy<MyClass>(() => new MyClass());
public static MyClass Instance => _singleton.Value;
Is there a way to create a PostSharp aspect that would allow me to add an attribute (PsSingleton) to the Instance
property as such:
[PsSingleton]
public static MyClass Instance {get; set;}
and have the class become a lazy singleton at run-time?