Skip to content

Commit 3f952a6

Browse files
committed
Extended explanation for ResetAttributeDescriptors()
The reasoning for calling `ResetAttributeDescriptors()` may not be immediately obvious if a reader isn't deeply familiar with how the inheritance of attributes works, and how that is modeled in the `ContentTypeDescriptor.AttributeDescriptors` property. To help bridge that gap, I've added more thorough explanations inline.
1 parent df7e6d2 commit 3f952a6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

OnTopic/Repositories/TopicRepositoryBase.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ topic is ContentTypeDescriptor descriptor &&
366366

367367
/*------------------------------------------------------------------------------------------------------------------------
368368
| If new attribute, refresh cache
369+
>-------------------------------------------------------------------------------------------------------------------------
370+
| Every ContentTypeDescriptor has an AttributeDescriptors property which includes references to all local and inherited
371+
| AttributeDescriptors. When a new AttributeDescriptor is added, these collections are reset for the current
372+
| ContentTypeDescriptor and all descendents to ensure that they all reflect the new AttributeDescriptor.
369373
\-----------------------------------------------------------------------------------------------------------------------*/
370374
if (topic.IsNew && IsAttributeDescriptor(topic)) {
371375
ResetAttributeDescriptors(topic);
@@ -435,6 +439,10 @@ public virtual void Move([ValidatedNotNull, NotNull]Topic topic, [ValidatedNotNu
435439

436440
/*------------------------------------------------------------------------------------------------------------------------
437441
| If a content type descriptor is being moved to a new parent, refresh cache
442+
>-------------------------------------------------------------------------------------------------------------------------
443+
| Attributes are inherited from parent content types, and stored in the ContentTypeDescriptor.AttributeDescriptors
444+
| collection. As such, when a content type is moved to a new location, the attribute descriptors for itself and all
445+
| descendants needs to be reset to ensure the inheritance structure is updated.
438446
\-----------------------------------------------------------------------------------------------------------------------*/
439447
if (topic.Parent != target && topic is ContentTypeDescriptor) {
440448
ResetAttributeDescriptors(topic);

0 commit comments

Comments
 (0)