Skip to content

Commit 909894d

Browse files
committed
[Critical] Fixed issues with Topic construction
While the `id` value is optional on the constructor, `Activator.CreateInstance()` doesn't honor that; to function, an `id` value _must_ be provided. In addition, before properties can be set, the `Attributes` property must be initialized.
1 parent 3e62952 commit 909894d

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

Ignia.Topics/Topic.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ public class Topic {
5555
/// <returns>A strongly-typed instance of the <see cref="Topic"/> class based on the target content type.</returns>
5656
public Topic(string key, string contentType, Topic parent, int id = -1) {
5757

58+
/*----------------------------------------------------------------------------------------------------------------------
59+
| Set relationships
60+
\---------------------------------------------------------------------------------------------------------------------*/
61+
Children = new TopicCollection(this);
62+
Attributes = new AttributeValueCollection(this);
63+
IncomingRelationships = new RelatedTopicCollection(this, true);
64+
Relationships = new RelatedTopicCollection(this, false);
65+
VersionHistory = new List<DateTime>();
66+
5867
/*----------------------------------------------------------------------------------------------------------------------
5968
| Set core properties
6069
\---------------------------------------------------------------------------------------------------------------------*/
@@ -74,15 +83,6 @@ public Topic(string key, string contentType, Topic parent, int id = -1) {
7483
}
7584
}
7685

77-
/*----------------------------------------------------------------------------------------------------------------------
78-
| Set relationships
79-
\---------------------------------------------------------------------------------------------------------------------*/
80-
Children = new TopicCollection(this);
81-
Attributes = new AttributeValueCollection(this);
82-
IncomingRelationships = new RelatedTopicCollection(this, true);
83-
Relationships = new RelatedTopicCollection(this, false);
84-
VersionHistory = new List<DateTime>();
85-
8686
}
8787

8888
#region Core Properties

Ignia.Topics/TopicFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public static Topic Create(string key, string contentType, Topic parent = null)
148148
/*----------------------------------------------------------------------------------------------------------------------
149149
| Identify the appropriate topic
150150
\---------------------------------------------------------------------------------------------------------------------*/
151-
var topic = (Topic)Activator.CreateInstance(targetType, key, contentType, parent);
151+
var topic = (Topic)Activator.CreateInstance(targetType, key, contentType, parent, -1);
152152

153153
/*----------------------------------------------------------------------------------------------------------------------
154154
| Return the topic

0 commit comments

Comments
 (0)