Skip to content

Commit 5e40470

Browse files
committed
Moved isIncoming overloads on RelatedTopicCollection to internal
The `isIncoming` parameter is used to maintain referential integrity within the topic graph, and is not intended to be called by external implementors. Given this, the methods which use `isIncoming` have been marked as `internal` to avoid confusion. As part of this, the optional `isDirty` parameter for `SetTopic()` has been moved to the public overload, since that _is_ required externally—and is actively used by `ITopicRepository` implementations. Note that the (now) internal `SetTopic()` overload's parameter order has changed, to maintain consistency with the public version. As there's only one internal call to it, however, this is not expected to matter.
1 parent ac01bbf commit 5e40470

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

OnTopic.Data.Sql/SqlDataReaderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private static void SetRelationships(this SqlDataReader reader, Dictionary<int,
318318
/*------------------------------------------------------------------------------------------------------------------------
319319
| Set relationship on object
320320
\-----------------------------------------------------------------------------------------------------------------------*/
321-
current.Relationships.SetTopic(relationshipKey, related, isIncoming: false, isDirty: false);
321+
current.Relationships.SetTopic(relationshipKey, related, isDirty: false);
322322

323323
}
324324

OnTopic/Collections/RelatedTopicCollection.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public class RelatedTopicCollection : KeyedCollection<string, NamedTopicCollecti
3939
/// The constructor requires a reference to a <see cref="Topic"/> instance, which the related topics are to be associated
4040
/// with. This will be used when setting incoming relationships. In addition, a <see cref="RelatedTopicCollection"/> may
4141
/// be set as <paramref name="isIncoming"/> if it is specifically intended to track incoming relationships; if this is not
42-
/// set, then it will not allow incoming relationships to be set via the internal
43-
/// <see cref="SetTopic(String, Topic, Boolean, Boolean?)"/> overload.
42+
/// set, then it will not allow incoming relationships to be set via the internal <see cref=
43+
/// "SetTopic(String, Topic, Boolean?, Boolean)"/> overload.
4444
/// </remarks>
4545
public RelatedTopicCollection(Topic parent, bool isIncoming = false) : base(StringComparer.OrdinalIgnoreCase) {
4646
_parent = parent;
@@ -124,6 +124,17 @@ public void ClearTopics(string relationshipKey) {
124124
/*==========================================================================================================================
125125
| METHOD: REMOVE TOPIC
126126
\-------------------------------------------------------------------------------------------------------------------------*/
127+
/// <summary>
128+
/// Removes a specific <see cref="Topic"/> object associated with a specific relationship key.
129+
/// </summary>
130+
/// <param name="relationshipKey">The key of the relationship.</param>
131+
/// <param name="topicKey">The key of the topic to be removed.</param>
132+
/// <returns>
133+
/// Returns true if the <see cref="Topic"/> is removed; returns false if either the relationship key or the
134+
/// <see cref="Topic"/> cannot be found.
135+
/// </returns>
136+
public bool RemoveTopic(string relationshipKey, string topicKey) => RemoveTopic(relationshipKey, topicKey);
137+
127138
/// <summary>
128139
/// Removes a specific <see cref="Topic"/> object associated with a specific relationship key.
129140
/// </summary>
@@ -136,7 +147,7 @@ public void ClearTopics(string relationshipKey) {
136147
/// Returns true if the <see cref="Topic"/> is removed; returns false if either the relationship key or the
137148
/// <see cref="Topic"/> cannot be found.
138149
/// </returns>
139-
public bool RemoveTopic(string relationshipKey, string topicKey, bool isIncoming = false) {
150+
internal bool RemoveTopic(string relationshipKey, string topicKey, bool isIncoming = false) {
140151

141152
/*------------------------------------------------------------------------------------------------------------------------
142153
| Validate contracts
@@ -227,7 +238,11 @@ public bool RemoveTopic(string relationshipKey, Topic topic, bool isIncoming = f
227238
/// </remarks>
228239
/// <param name="relationshipKey">The key of the relationship.</param>
229240
/// <param name="topic">The topic to be added, if it doesn't already exist.</param>
230-
public void SetTopic(string relationshipKey, Topic topic) => SetTopic(relationshipKey, topic, false);
241+
/// <param name="isDirty">
242+
/// Optionally forces the collection to a <see cref="NamedTopicCollection.IsDirty"/> state, assuming the topic was set.
243+
/// </param>
244+
public void SetTopic(string relationshipKey, Topic topic, bool? isDirty = null)
245+
=> SetTopic(relationshipKey, topic, isDirty, false);
231246

232247
/// <summary>
233248
/// Ensures that an incoming <see cref="Topic"/> is associated with the specified relationship key.
@@ -243,7 +258,7 @@ public bool RemoveTopic(string relationshipKey, Topic topic, bool isIncoming = f
243258
/// <param name="isDirty">
244259
/// Optionally forces the collection to a <see cref="NamedTopicCollection.IsDirty"/> state, assuming the topic was set.
245260
/// </param>
246-
public void SetTopic(string relationshipKey, Topic topic, bool isIncoming, bool? isDirty = null) {
261+
internal void SetTopic(string relationshipKey, Topic topic, bool? isDirty, bool isIncoming) {
247262

248263
/*------------------------------------------------------------------------------------------------------------------------
249264
| Validate contracts

OnTopic/Metadata/ContentTypeDescriptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public bool DisableChildTopics {
126126
/// </para>
127127
/// <para>
128128
/// To add content types to the <see cref="PermittedContentTypes"/> collection, use <see
129-
/// cref="RelatedTopicCollection.SetTopic(String, Topic, Boolean, Boolean?)"/>.
129+
/// cref="RelatedTopicCollection.SetTopic(String, Topic, Boolean?)"/>.
130130
/// </para>
131131
/// </remarks>
132132
public ReadOnlyTopicCollection<ContentTypeDescriptor> PermittedContentTypes {

0 commit comments

Comments
 (0)