Skip to content

Commit ffe775e

Browse files
committed
Applied ITopicBindingModel to ITopicViewModel
Since `ContentType` is defined on both `ITopicBindingModel` and `ITopicBindingModel`, and there's no other "pollution" from any otherwise unnecessary interface requirements on `ITopicBindingModel`, we can derive `ITopicBindingModel` from `ITopicBindingModel`, thus allowing them to share this definition, while also allowing implementations to satisfy both interfaces. This can also be applied to `TopicViewModel`.
1 parent 8ad42b9 commit ffe775e

2 files changed

Lines changed: 10 additions & 22 deletions

File tree

OnTopic.ViewModels/TopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace OnTopic.ViewModels {
2020
/// default implementations that can be used directly, used as base classes, or overwritten at the presentation level. They
2121
/// are supplied for convenience to model factory default settings for out-of-the-box content types.
2222
/// </remarks>
23-
public record TopicViewModel: ITopicViewModel, IKeyedTopicViewModel, IAssociatedTopicBindingModel {
23+
public record TopicViewModel: ITopicViewModel, IKeyedTopicViewModel, IAssociatedTopicBindingModel, ITopicBindingModel {
2424

2525
/*==========================================================================================================================
2626
| ID

OnTopic/Models/ITopicViewModel.cs

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ namespace OnTopic.Models {
2222
/// provided via the public interface then it will instead need to be defined in some other way.
2323
/// </para>
2424
/// <para>
25-
/// For instance, in the default MVC library, the <c>TopicViewResult</c> class requires that the <see
26-
/// cref="Topic.ContentType"/> and <see cref="Topic.View"/> be supplied separately if they're not provided as part of a
27-
/// <see cref="ITopicViewModel"/>. The exact details of this will obviously vary based on the implementation of the
28-
/// presentation layer and any supporting libraries.
25+
/// For instance, in the default MVC library, the <c>TopicViewResult</c> class requires that the <see cref="Topic.
26+
/// ContentType"/> and <see cref="Topic.View"/> be supplied separately if they're not provided as part of a <see cref="
27+
/// ITopicViewModel"/>. The exact details of this will obviously vary based on the implementation of the presentation
28+
/// layer and any supporting libraries.
2929
/// </para>
3030
/// </remarks>
31-
public interface ITopicViewModel: IKeyedTopicViewModel, IAssociatedTopicBindingModel {
31+
public interface ITopicViewModel: IKeyedTopicViewModel, IAssociatedTopicBindingModel, ITopicBindingModel {
3232

3333
/*==========================================================================================================================
3434
| PROPERTY: ID
@@ -47,18 +47,6 @@ public interface ITopicViewModel: IKeyedTopicViewModel, IAssociatedTopicBindingM
4747
/// </summary>
4848
string? WebPath { get; init; }
4949

50-
/*==========================================================================================================================
51-
| PROPERTY: CONTENT TYPE
52-
\-------------------------------------------------------------------------------------------------------------------------*/
53-
/// <summary>
54-
/// Gets the key name of the content type that the current topic represents.
55-
/// </summary>
56-
/// <remarks>
57-
/// Each topic is associated with a content type. The content type determines which attributes are displayed in the Topics
58-
/// Editor (via the <see cref="ContentTypeDescriptor.AttributeDescriptors"/> property).
59-
/// </remarks>
60-
string? ContentType { get; init; }
61-
6250
/*==========================================================================================================================
6351
| PROPERTY: VIEW
6452
\-------------------------------------------------------------------------------------------------------------------------*/
@@ -67,10 +55,10 @@ public interface ITopicViewModel: IKeyedTopicViewModel, IAssociatedTopicBindingM
6755
/// </summary>
6856
/// <remarks>
6957
/// This value can be set via the query string (via the <c>TopicViewResultExecutor</c> class), via the Accepts header
70-
/// (also via the <c>TopicViewResultExecutor</c> class), on the topic itself (via this property), or via the
71-
/// <see cref="ContentType"/>. By default, it will be set to the name of the <see cref="ContentType"/>; e.g., if the
72-
/// Content Type is "Page", then the view will be "Page". This will cause the <c>TopicViewResultExecutor</c> to look
73-
/// for a view at, for instance, <c>/Views/Page/Page.cshtml</c>.
58+
/// (also via the <c>TopicViewResultExecutor</c> class), on the topic itself (via this property), or via the <see cref="
59+
/// ITopicBindingModel.ContentType"/>. By default, it will be set to the name of the <see cref="ITopicBindingModel.
60+
/// ContentType"/>; e.g., if the Content Type is <c>Page</c>, then the view will be <c>Page</c>. This will cause the <c>
61+
/// TopicViewResultExecutor</c> to look for a view at, for instance, <c>/Views/Page/Page.cshtml</c>.
7462
/// </remarks>
7563
string? View { get; init; }
7664

0 commit comments

Comments
 (0)