Commit 408d01a
committed
Introduced new
On the surface, the new `GetContentTypeDescriptor()` appears to just be a convenience method for checking the `GetContentTypeDescriptors() to determine if it contains the `ContentTypeDescriptor` associated with the current `Topic` and, if so, returning it.
The `GetContentTypeDescriptor()` method does a lot more than this, however. If the `ContentTypeDescriptor` _cannot_ be found, then it attempts to locate the `Root:Configuration:ContentTypes` topic within the in-memory topic graph using the new `GetTopicByUniqueKey()` extension method (f2cb109). If found, it will then merge that tree with the `GetContentTypeDescriptors()` cache by using the new overload (7a5a243). In this way, it is able to fall back from persisted `ContentTypeDescriptor`s loaded from the database to potentially rely on new—but not yet persisted—`ContentTypeDescriptor`s available in the current graph.
As part of this, the new `GetContentTypeDescriptor()` method is used for the content type lookups in the local `GetAttributes()` and `GetUnmatchedAttributes()` methods, which are in turn used by the concrete `Save()` implementation.
This provides a reactive solution for the discovering in-memory `ContentTypeDescriptor` on `Save()` (#18). In practice, we'll generally prefer a proactive solution by updating these as `ContentTypeDescriptor`s when they're saved, instead of discovering them only when `Save()` is unable to find them. That will be addressed in a future commit.
For now, however, this provides a fallback implementation, and will be necessary for supporting more complex scenarios such as bootstrapping the database, or otherwise importing complex topic graphs using e.g. the **OnTopic Data Exchange** library.
Includes two unit tests for validating the functionality.GetContentTypeDescriptor() method1 parent 7a5a243 commit 408d01a
3 files changed
Lines changed: 90 additions & 3 deletions
File tree
- OnTopic.TestDoubles
- OnTopic.Tests
- OnTopic/Repositories
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
187 | 194 | | |
188 | 195 | | |
189 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
171 | 203 | | |
172 | 204 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
142 | 190 | | |
143 | 191 | | |
144 | 192 | | |
| |||
383 | 431 | | |
384 | 432 | | |
385 | 433 | | |
386 | | - | |
| 434 | + | |
387 | 435 | | |
388 | 436 | | |
389 | 437 | | |
| |||
432 | 480 | | |
433 | 481 | | |
434 | 482 | | |
435 | | - | |
| 483 | + | |
436 | 484 | | |
437 | 485 | | |
438 | 486 | | |
439 | | - | |
| 487 | + | |
440 | 488 | | |
441 | 489 | | |
442 | 490 | | |
| |||
0 commit comments