Recently I've adopted a handy way to make sure tree-like structure members are aware of their parent node:
private metaCollection<metaPage> _servicePages;
/// <summary>
/// Registry of service pages used by this document
/// </summary>
[Category("metaDocument")]
[DisplayName("servicePages")]
[Description("Registry of service pages used by this document")]
public metaCollection<metaPage> servicePages
{
get
{
if (_servicePages == null) {
_servicePages = new metaCollection<metaPage>();
_servicePages.parent = this;
}
return _servicePages;
}
}
(the concept is to create instance for private field within property get method)
I would love to know if this pattern has some common-known name? and even more: are there known issues / bad implications on such practice?
Thanks!