I have some auto-instantiation code which I would like to apply to about 15 properties in a fairly big class. The code is similar to the following but the type is differ
This might make things a bit neater, you could add this method to introduce some reuse:
protected ComplexType _propertyName;
public ComplexType PropertyName
{
get
{
return GetProperty(ref _propertyName);
}
}
.
.
private T GetProperty(ref T property) where T : new()
{
if (property == null)
property = new T();
return property;
}