@@ -31,12 +31,7 @@ public class Topic : IDisposable {
3131 private string _key = null ;
3232 private string _originalKey = null ;
3333 private Topic _parent = null ;
34- private TopicCollection _children = null ;
35- private AttributeValueCollection _attributes = null ;
36- private RelatedTopicCollection _relationships = null ;
37- private RelatedTopicCollection _incomingRelationships = null ;
3834 private Topic _derivedTopic = null ;
39- private List < DateTime > _versionHistory = null ;
4035
4136 /*==========================================================================================================================
4237 | CONSTRUCTOR
@@ -47,7 +42,14 @@ public class Topic : IDisposable {
4742 /// <summary>
4843 /// Initializes a new instance of the <see cref="Topic"/> class.
4944 /// </summary>
50- public Topic ( ) { }
45+ public Topic ( ) {
46+ Children = new TopicCollection ( this ) ;
47+ Attributes = new AttributeValueCollection ( this ) ;
48+ IncomingRelationships = new RelatedTopicCollection ( this , true ) ;
49+ Relationships = new RelatedTopicCollection ( this , false ) ;
50+ VersionHistory = new List < DateTime > ( ) ;
51+
52+ }
5153
5254 #region Core Properties
5355
@@ -103,15 +105,7 @@ public Topic Parent {
103105 /// <summary>
104106 /// Provides a keyed collection of child <see cref="Topic"/> instances associated with the current <see cref="Topic"/>.
105107 /// </summary>
106- public TopicCollection Children {
107- get {
108- Contract . Ensures ( Contract . Result < TopicCollection > ( ) != null ) ;
109- if ( _children == null ) {
110- _children = new TopicCollection ( this ) ;
111- }
112- return _children ;
113- }
114- }
108+ public TopicCollection Children { get ; }
115109
116110 /*==========================================================================================================================
117111 | PROPERTY: IS EMPTY
@@ -516,14 +510,7 @@ public Topic DerivedTopic {
516510 /// property) and whether it has been persisted to the database or not (via the <see cref="AttributeValue.IsDirty"/>
517511 /// property).
518512 /// </remarks>
519- public AttributeValueCollection Attributes {
520- get {
521- Contract . Ensures ( Contract . Result < AttributeValueCollection > ( ) != null ) ;
522- if ( _attributes == null ) {
523- _attributes = new AttributeValueCollection ( this ) ;
524- }
525- return _attributes ;
526- }
513+ public AttributeValueCollection Attributes { get ; }
527514
528515 /*==========================================================================================================================
529516 | PROPERTY: RELATIONSHIPS
@@ -536,15 +523,7 @@ public AttributeValueCollection Attributes {
536523 /// "Related" for related topics); those child topics in turn have child topics representing references to each related
537524 /// topic, thus allowing the topic hierarchy to be represented as a network graph.
538525 /// </remarks>
539- public RelatedTopicCollection Relationships {
540- get {
541- Contract . Ensures ( Contract . Result < RelatedTopicCollection > ( ) != null ) ;
542- if ( _relationships == null ) {
543- _relationships = new RelatedTopicCollection ( this , false ) ;
544- }
545- return _relationships ;
546- }
547- }
526+ public RelatedTopicCollection Relationships { get ; }
548527
549528 /*===========================================================================================================================
550529 | PROPERTY: INCOMING RELATIONSHIPS
@@ -558,15 +537,7 @@ public RelatedTopicCollection Relationships {
558537 /// This is of particular use for tags, where the current topic represents a tag, and the incoming relationships represents
559538 /// all topics associated with that tag.
560539 /// </remarks>
561- public RelatedTopicCollection IncomingRelationships {
562- get {
563- Contract . Ensures ( Contract . Result < RelatedTopicCollection > ( ) != null ) ;
564- if ( _incomingRelationships == null ) {
565- _incomingRelationships = new RelatedTopicCollection ( this , true ) ;
566- }
567- return _incomingRelationships ;
568- }
569- }
540+ public RelatedTopicCollection IncomingRelationships { get ; }
570541
571542 /*==========================================================================================================================
572543 | PROPERTY: VERSION HISTORY
@@ -578,15 +549,7 @@ public RelatedTopicCollection IncomingRelationships {
578549 /// It is expected that this collection will be populated by the <see cref="Repositories.ITopicRepository"/> (or one of
579550 /// its derived providers).
580551 /// </remarks>
581- public List < DateTime> VersionHistory {
582- get {
583- Contract . Ensures ( Contract . Result < List < DateTime > > ( ) != null ) ;
584- if ( _versionHistory == null ) {
585- _versionHistory = new List < DateTime > ( ) ;
586- }
587- return _versionHistory ;
588- }
589- }
552+ public List < DateTime > VersionHistory { get ; }
590553
591554 #endregion
592555
0 commit comments