I have my own attribute [Finder] for fields and properties, and I have a kind of factory that initializing all fields and properties as I want.
Question:
I want to do kind of lazy initialization(object be created only when I calling some methods of this object) for objects that i’m initializing.
Note: properties and fields could be different types.
I have my own attribute [Finder] for fields and properties, and I have a
Share
Depending on how the initialization happens, you can use the new
Lazy<T>type. Another possibility would be to return a automatically created subclass of your class – a proxy – that checks the state of the initialization at every method call and executed the initialization if necessary.