Skip to content

Commit 78a9d3f

Browse files
committed
Introduced new SetContentTypeDescriptors() overload
The initial overload of `SetContentTypeDescriptors()` (f1ade10) operated just like the `GetContentTypeDescriptors()` method it replaced in that it accepted a `ContentTypeDescriptor`—which it expected to be the _root_ `ContentTypeDescriptor` (i.e., `Root:Configuration:ContentTypes`) (b206f3e) This overload provides a bit more flexibility by allowing a caller to submit _any_ `Topic`—not just a `ContentTypeDescriptor`—from _anywhere_ within the topic graph—not just `Root:Configuration:ContentTypes`. This is just a convenience method to make it really easy to update the content type configuration by passing in a reference to the topic graph via any node in that graph, and trusting it to find the node it relies on. (This process is easy with the newish `GetByUniqueKey()` extension method, but it's still handy having it centralized, instead of needing to do that lookup each time it's called.)
1 parent f1ade10 commit 78a9d3f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

OnTopic/Repositories/TopicRepositoryBase.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ protected virtual ContentTypeDescriptorCollection GetContentTypeDescriptors(Cont
112112
/*==========================================================================================================================
113113
| SET CONTENT TYPE DESCRIPTORS
114114
\-------------------------------------------------------------------------------------------------------------------------*/
115+
/// <summary>
116+
/// Allows for the content type descriptor cache to be (re)initialized based on an in-memory topic graph, by first
117+
/// identifying the root <see cref="ContentTypeDescriptor"/> from within the current content graph.
118+
/// </summary>
119+
/// <param name="sourceTopic">
120+
/// A <see cref="Topic"/> within the source topic graph. This overload will use this topic to identify the root <see cref=
121+
/// "ContentTypeDescriptor"/> within the graph.
122+
/// </param>
123+
/// <returns></returns>
124+
protected virtual ContentTypeDescriptorCollection SetContentTypeDescriptors(Topic? sourceTopic) =>
125+
SetContentTypeDescriptors(sourceTopic?.GetByUniqueKey("Root:Configuration:ContentTypes") as ContentTypeDescriptor);
126+
115127
/// <summary>
116128
/// Allows for the content type descriptor cache to be (re)initialized based on an in-memory topic graph, starting with
117129
/// the root <see cref="ContentTypeDescriptor"/>.

0 commit comments

Comments
 (0)