Skip to content

Commit c37934b

Browse files
committed
Added a MarkClean() method to RelatedTopicCollection
There was previously no way to mark all relationships as clean without looping through the list of `NamedTopicCollections` and flipping the `IsDirty` value of each. That's all the new `MarkClean()` method does as well, but it centralizes the logic in the `RelatedTopicCollection`, and offers consistency with other collections that use the `IsDirty()`/`MarkClean()` convention (e.g., `AttributeValueCollection`).
1 parent 265e2e5 commit c37934b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

OnTopic/Collections/RelatedTopicCollection.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,19 @@ internal void SetTopic(string relationshipKey, Topic topic, bool? isDirty, bool
314314
/// </summary>
315315
public bool IsDirty() => Items.Any(r => r.IsDirty);
316316

317+
/*==========================================================================================================================
318+
| METHOD: MARK CLEAN
319+
\-------------------------------------------------------------------------------------------------------------------------*/
320+
/// <summary>
321+
/// Sets the <see cref="NamedTopicCollection.IsDirty"/> property of every <see cref="NamedTopicCollection"/> in this <see
322+
/// cref="RelatedTopicCollection"/> to <c>false</c>.
323+
/// </summary>
324+
public void MarkClean() {
325+
foreach (var relationship in Items) {
326+
relationship.IsDirty = false;
327+
}
328+
}
329+
317330
/*==========================================================================================================================
318331
| OVERRIDE: INSERT ITEM
319332
\-------------------------------------------------------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)