Skip to content

Commit 35ca7f5

Browse files
committed
Introduced AttributeDictionary constructor for relationships
The `RelationshipAttributeDescriptorViewModel` was inadvertently missed when originally implementing the `AttributeDictionary` constructor overloads on the `AttributeDescriptorViewModel` implementations (7e15db9). This doesn't _harm_ anything, but it also prevents this particular attribute from taking advantage of the performance benefits of the `AttributeDictionary` constructor.
1 parent 87a93f0 commit 35ca7f5

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

OnTopic.Editor.AspNetCore.Attributes/RelationshipAttribute/RelationshipAttributeDescriptorViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,33 @@ public record RelationshipAttributeDescriptorViewModel: QueryableTopicListAttrib
1818
/*==========================================================================================================================
1919
| CONSTRUCTOR
2020
\-------------------------------------------------------------------------------------------------------------------------*/
21+
/// <summary>
22+
/// Initializes a new <see cref="RelationshipAttributeDescriptorViewModel"/> with an <paramref name="attributes"/> dictionary.
23+
/// </summary>
24+
/// <param name="attributes">An <see cref="AttributeDictionary"/> of attribute values.</param>
25+
public RelationshipAttributeDescriptorViewModel(AttributeDictionary attributes): base(attributes) {
26+
Contract.Requires(attributes, nameof(attributes));
27+
ShowRoot = attributes.GetBoolean(nameof(ShowRoot));
28+
ExpandRelated = attributes.GetBoolean(nameof(ExpandRelated));
29+
CheckAscendants = attributes.GetBoolean(nameof(CheckAscendants));
30+
RegisterResources();
31+
}
32+
2133
/// <summary>
2234
/// Initializes a new instance of a <see cref="RelationshipAttributeDescriptorViewModel"/>
2335
/// </summary>
2436
public RelationshipAttributeDescriptorViewModel() {
37+
RegisterResources();
38+
}
39+
40+
/*==========================================================================================================================
41+
| REGISTER RESOURCES
42+
\-------------------------------------------------------------------------------------------------------------------------*/
43+
/// <summary>
44+
/// Derived classes may optionally override this method in order to register resources, as an alternative to setting these
45+
/// in the constructor.
46+
/// </summary>
47+
protected void RegisterResources() {
2548
Scripts.Register(GetNamespacedUri("/Shared/Scripts/SelectableTreeView.js"));
2649
}
2750

0 commit comments

Comments
 (0)