Skip to content

Commit 1daf799

Browse files
committed
Renamed RelationshipType to CollectionType
This corresponds to the rename of the `[Relationship()]` attribute to `[Collection()]`. This also has a large downstream effect, since `PropertyConfiguration` has a `RelationshipType` property, and there are a lot of related `relationshipType` variables throughout the code base.
1 parent f84ae66 commit 1daf799

12 files changed

+68
-70
lines changed

OnTopic.Tests/BindingModels/InvalidRelationshipTypeTopicBindingModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ namespace OnTopic.Tests.BindingModels {
1414
| BINDING MODEL: RELATIONSHIP TYPE TOPIC (INVALID)
1515
\---------------------------------------------------------------------------------------------------------------------------*/
1616
/// <summary>
17-
/// Provides a custom binding model with an invalid <see cref="RelationshipType"/>—i.e., it refers to <see
18-
/// cref="RelationshipType.NestedTopics"/>, even though the property is associated with a <see
19-
/// cref="RelationshipType.Relationship"/>. An <see cref="InvalidOperationException"/> should be thrown when it is mapped.
17+
/// Provides a custom binding model with an invalid <see cref="CollectionType"/>—i.e., it refers to <see cref="
18+
/// CollectionType.NestedTopics"/>, even though the property is associated with a <see cref="CollectionType.Relationship"/>.
19+
/// An <see cref="InvalidOperationException"/> should be thrown when it is mapped.
2020
/// </summary>
2121
/// <remarks>
2222
/// This is a sample class intended for test purposes only; it is not designed for use in a production environment.
@@ -25,7 +25,7 @@ public class InvalidRelationshipTypeTopicBindingModel : BasicTopicBindingModel {
2525

2626
public InvalidRelationshipTypeTopicBindingModel(string? key = null) : base(key, "ContentTypeDescriptor") { }
2727

28-
[Collection(RelationshipType.NestedTopics)]
28+
[Collection(CollectionType.NestedTopics)]
2929
public Collection<RelatedTopicBindingModel> ContentTypes { get; } = new();
3030

3131
} //Class

OnTopic.Tests/ReverseTopicMappingServiceTest.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,9 @@ public async Task Map_InvalidRelationshipBaseType_ThrowsInvalidOperationExceptio
440440
| TEST: MAP: INVALID RELATIONSHIP TYPE: THROWS INVALID OPERATION EXCEPTION
441441
\-------------------------------------------------------------------------------------------------------------------------*/
442442
/// <summary>
443-
/// Maps a content type that has a relationship an invalid <see cref="RelationshipType"/>—i.e., it refers to <see
444-
/// cref="RelationshipType.NestedTopics"/>, even though the property is associated with a <see
445-
/// cref="RelationshipType.Relationship"/>. This is invalid, and expected to throw an <see
446-
/// cref="InvalidOperationException"/>.
443+
/// Maps a content type that has a relationship with an invalid <see cref="CollectionType"/>—i.e., it refers to <see cref=
444+
/// "CollectionType.NestedTopics"/>, even though the property is associated with a <see cref="CollectionType.Relationship"
445+
/// />. This is invalid, and expected to throw an <see cref="InvalidOperationException"/>.
447446
/// </summary>
448447
[TestMethod]
449448
[ExpectedException(typeof(MappingModelValidationException))]

OnTopic.Tests/TopicMappingServiceTest.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,11 @@ public async Task Map_Relationships_SkipsDisabled() {
387387
/// type specified by <see cref="Mapping.Annotations.CollectionAttribute"/>.
388388
/// </summary>
389389
/// <remarks>
390-
/// The <see cref="AmbiguousRelationTopicViewModel.RelationshipAlias"/> uses <see
391-
/// cref="Mapping.Annotations.CollectionAttribute"/> to set the relationship key to <c>AmbiguousRelationship</c> and the
392-
/// <see cref="RelationshipType"/> to <see cref="RelationshipType.IncomingRelationship"/>. <c>AmbiguousRelationship</c>
393-
/// refers to a relationship that is both outgoing and incoming. It should be smart enough to a) look for the
394-
/// <c>AmbigousRelationship</c> instead of the <c>RelationshipAlias</c>, and b) source from the <see
395-
/// cref="Topic.IncomingRelationships"/> collection.
390+
/// The <see cref="AmbiguousRelationTopicViewModel.RelationshipAlias"/> uses <see cref="Mapping.Annotations.
391+
/// CollectionAttribute"/> to set the relationship key to <c>AmbiguousRelationship</c> and the <see cref="CollectionType"
392+
/// /> to <see cref="CollectionType.IncomingRelationship"/>. <c>AmbiguousRelationship</c> refers to a relationship that is
393+
/// both outgoing and incoming. It should be smart enough to a) look for the <c>AmbigousRelationship</c> instead of the
394+
/// <c>RelationshipAlias</c>, and b) source from the <see cref="Topic.IncomingRelationships"/> collection.
396395
/// </remarks>
397396
[TestMethod]
398397
public async Task Map_AlternateRelationship_ReturnsCorrectRelationship() {

OnTopic.Tests/ViewModels/AmbiguousRelationTopicViewModel.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@ namespace OnTopic.Tests.ViewModels {
1616
/// </summary>
1717
/// <remarks>
1818
/// <para>
19-
/// The <see cref="RelationshipAlias"/> uses <see cref="CollectionAttribute"/> to set the relationship key to
20-
/// <c>AmbiguousRelationship</c> and the <see cref="RelationshipType"/> to <see
21-
/// cref="RelationshipType.IncomingRelationship"/>. <c>AmbiguousRelationship</c> refers to a relationship that is both
22-
/// outgoing and incoming.
19+
/// The <see cref="RelationshipAlias"/> uses <see cref="CollectionAttribute"/> to set the relationship key to <c>
20+
/// AmbiguousRelationship</c> and the <see cref="CollectionType"/> to <see cref="CollectionType.IncomingRelationship"/>.
21+
/// <c>AmbiguousRelationship</c> refers to a relationship that is both outgoing and incoming.
2322
/// </para>
2423
/// <para>
2524
/// This is a sample class intended for test purposes only; it is not designed for use in a production environment.
2625
/// </para>
2726
/// </remarks>
2827
public class AmbiguousRelationTopicViewModel: KeyOnlyTopicViewModel {
2928

30-
[Collection("AmbiguousRelationship", Type=RelationshipType.IncomingRelationship)]
29+
[Collection("AmbiguousRelationship", Type= CollectionType.IncomingRelationship)]
3130
public Collection<KeyOnlyTopicViewModel> RelationshipAlias { get; } = new();
3231

3332
} //Class

OnTopic.Tests/ViewModels/Metadata/ContentTypeDescriptorTopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ContentTypeDescriptorTopicViewModel {
2222

2323
public Collection<AttributeDescriptorTopicViewModel> AttributeDescriptors { get; } = new();
2424

25-
[Collection(RelationshipType.MappedCollection)]
25+
[Collection(CollectionType.MappedCollection)]
2626
[Follow(Relationships.None)]
2727
public Collection<ContentTypeDescriptorTopicViewModel> PermittedContentTypes { get; } = new();
2828

OnTopic/Mapping/Annotations/CollectionAttribute.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,29 @@ public CollectionAttribute(string key) {
4343
}
4444

4545
/// <summary>
46-
/// Annotates a property with the <see cref="CollectionAttribute"/> by providing the <see cref="RelationshipType"/>.
46+
/// Annotates a property with the <see cref="CollectionAttribute"/> by providing the <see cref="CollectionType"/>.
4747
/// </summary>
4848
/// <param name="type">Optional. The type of collection the relationship is associated with.</param>
49-
public CollectionAttribute(RelationshipType type = RelationshipType.Any) {
49+
public CollectionAttribute(CollectionType type = CollectionType.Any) {
5050
Type = type;
5151
}
5252

5353
/*==========================================================================================================================
5454
| PROPERTY: KEY
5555
\-------------------------------------------------------------------------------------------------------------------------*/
5656
/// <summary>
57-
/// Gets the value of the relationship key.
57+
/// Gets the value of the collection key.
5858
/// </summary>
5959
public string? Key { get; }
6060

6161
/*==========================================================================================================================
6262
| PROPERTY: TYPE
6363
\-------------------------------------------------------------------------------------------------------------------------*/
6464
/// <summary>
65-
/// Gets the value of the relationship type.
65+
/// Gets the value of the <see cref="CollectionType"/>.
6666
/// </summary>
6767
#pragma warning disable CA1019 // Define accessors for attribute arguments
68-
public RelationshipType Type { get; set; }
68+
public CollectionType Type { get; set; }
6969
#pragma warning restore CA1019 // Define accessors for attribute arguments
7070

7171
} //Class

OnTopic/Mapping/Annotations/RelationshipType.cs renamed to OnTopic/Mapping/Annotations/CollectionType.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
namespace OnTopic.Mapping.Annotations {
88

99
/*============================================================================================================================
10-
| ENUM: RELATIONSHIP TYPE
10+
| ENUM: COLLECTION TYPE
1111
\---------------------------------------------------------------------------------------------------------------------------*/
1212
/// <summary>
13-
/// Enum that allows a relationship to be specified.
13+
/// Enum that allows a collection to be specified.
1414
/// </summary>
1515
/// <remarks>
16-
/// This differs from <see cref="Relationships"/>, which allows <i>multiple</i> relationships to be specified.
16+
/// This differs from <see cref="Relationships"/>, which allows <i>multiple</i> collections to be specified, and also
17+
/// includes the <see cref="Topic.Parent"/> as a source.
1718
/// </remarks>
18-
public enum RelationshipType {
19+
public enum CollectionType {
1920

2021
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
2122

OnTopic/Mapping/Annotations/Relationships.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace OnTopic.Mapping.Annotations {
2323
/// relevant to the <see cref="Topic"/> class and its view models.
2424
/// </para>
2525
/// <para>
26-
/// This differs from <see cref="RelationshipType"/>, which only allows <i>one</i> relationship to be specified.
26+
/// This differs from <see cref="CollectionType"/>, which only allows <i>one</i> collection to be specified.
2727
/// </para>
2828
/// </remarks>
2929
[Flags]
@@ -49,15 +49,15 @@ public enum Relationships {
4949
| CHILDREN
5050
\-------------------------------------------------------------------------------------------------------------------------*/
5151
/// <summary>
52-
/// Map <see cref="Topic.Children"/> references, or properties marked as <see cref="RelationshipType.Children"/>.
52+
/// Map <see cref="Topic.Children"/> references, or properties marked as <see cref="CollectionType.Children"/>.
5353
/// </summary>
5454
Children = 1 << 1,
5555

5656
/*==========================================================================================================================
5757
| RELATIONSHIPS
5858
\-------------------------------------------------------------------------------------------------------------------------*/
5959
/// <summary>
60-
/// Map <see cref="Topic.Relationships"/> references, or properties marked as <see cref="RelationshipType.Relationship"/>.
60+
/// Map <see cref="Topic.Relationships"/> references, or properties marked as <see cref="CollectionType.Relationship"/>.
6161
/// </summary>
6262
Relationships = 1 << 2,
6363

@@ -66,7 +66,7 @@ public enum Relationships {
6666
\-------------------------------------------------------------------------------------------------------------------------*/
6767
/// <summary>
6868
/// Map <see cref="Topic.IncomingRelationships"/> references, or properties marked as <see
69-
/// cref="RelationshipType.IncomingRelationship"/>.
69+
/// cref="CollectionType.IncomingRelationship"/>.
7070
/// </summary>
7171
IncomingRelationships = 1 << 3,
7272

OnTopic/Mapping/Internal/PropertyConfiguration.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public PropertyConfiguration(PropertyInfo property, string? attributePrefix = ""
6868
DefaultValue = null;
6969
InheritValue = false;
7070
RelationshipKey = AttributeKey;
71-
RelationshipType = RelationshipType.Any;
71+
CollectionType = CollectionType.Any;
7272
CrawlRelationships = Relationships.None;
7373
MetadataKey = null;
7474
DisableMapping = false;
@@ -96,12 +96,12 @@ public PropertyConfiguration(PropertyInfo property, string? attributePrefix = ""
9696
property,
9797
a => {
9898
RelationshipKey = a.Key ?? RelationshipKey;
99-
RelationshipType = a.Type;
99+
CollectionType = a.Type;
100100
}
101101
);
102102

103103
if (RelationshipKey.Equals("Children", StringComparison.OrdinalIgnoreCase)) {
104-
RelationshipType = RelationshipType.Children;
104+
CollectionType = CollectionType.Children;
105105
}
106106

107107
/*------------------------------------------------------------------------------------------------------------------------
@@ -264,17 +264,17 @@ public PropertyConfiguration(PropertyInfo property, string? attributePrefix = ""
264264
/// <para>
265265
/// By default, a collection property on a DTO class will attempt to find a match from, in order, <see
266266
/// cref="Topic.Relationships"/>, <see cref="Topic.IncomingRelationships"/>, and, finally, <see cref="Topic.Children"/>.
267-
/// If the <see cref="RelationshipType"/> is set, however, then the <see cref="ITopicMappingService"/> will <i>only</i>
267+
/// If the <see cref="CollectionType"/> is set, however, then the <see cref="ITopicMappingService"/> will <i>only</i>
268268
/// map the collection to a relationship of that type. This can be valuable when the <see cref="RelationshipKey"/> might
269269
/// be ambiguous between multiple collections.
270270
/// </para>
271271
/// <para>
272-
/// The <see cref="RelationshipType"/> property corresponds to the <see cref="CollectionAttribute.Type"/> property. It
272+
/// The <see cref="CollectionType"/> property corresponds to the <see cref="CollectionAttribute.Type"/> property. It
273273
/// can be assigned by decorating a DTO property with e.g. <c>[Relationship("AlternateRelationshipKey",
274-
/// RelationshipType.Children)]</c>.
274+
/// CollectionType.Children)]</c>.
275275
/// </para>
276276
/// </remarks>
277-
public RelationshipType RelationshipType { get; set; }
277+
public CollectionType CollectionType { get; set; }
278278

279279
/*==========================================================================================================================
280280
| PROPERTY: CRAWL RELATIONSHIPS
@@ -286,7 +286,7 @@ public PropertyConfiguration(PropertyInfo property, string? attributePrefix = ""
286286
/// <remarks>
287287
/// <para>
288288
/// By default, the all relationships will be mapped on the target DTO, unless the caller specifies otherwise. On any
289-
/// related DTOs, however, only <see cref="RelationshipType.NestedTopics"/> will be mapped. So, if a mapped DTO has a
289+
/// related DTOs, however, only <see cref="CollectionType.NestedTopics"/> will be mapped. So, if a mapped DTO has a
290290
/// collection for children, relationships, or even a parent property then any relationships on <i>those</i> DTOs will
291291
/// not be mapped. This behavior can be changed by specifying the <see cref="CrawlRelationships"/> flag, which allows
292292
/// one or multiple relationships to be specified for a given property.

OnTopic/Mapping/Internal/RelationshipMap.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ namespace OnTopic.Mapping.Internal {
1212
| CLASS: RELATIONSHIP MAP
1313
\---------------------------------------------------------------------------------------------------------------------------*/
1414
/// <summary>
15-
/// Provides a mapping of the relationship between <see cref="RelationshipType"/> and <see cref="Relationships"/>.
15+
/// Provides a mapping of the relationship between <see cref="CollectionType"/> and <see cref="Relationships"/>.
1616
/// </summary>
1717
/// <remarks>
18-
/// While the <see cref="RelationshipType"/> and <see cref="Relationships"/> enumerations are distinct, there are times when
19-
/// a single <see cref="RelationshipType"/> needs to be related to an item in the collection of <see cref="Relationships"/>.
18+
/// While the <see cref="CollectionType"/> and <see cref="Relationships"/> enumerations are distinct, there are times when
19+
/// a single <see cref="CollectionType"/> needs to be related to an item in the collection of <see cref="Relationships"/>.
2020
/// This mapping makes that feasible.
2121
/// </remarks>
2222
static internal class RelationshipMap {
@@ -26,13 +26,13 @@ static internal class RelationshipMap {
2626
\-------------------------------------------------------------------------------------------------------------------------*/
2727
static RelationshipMap() {
2828

29-
var mappings = new Dictionary<RelationshipType, Relationships> {
30-
{ RelationshipType.Any, Relationships.None },
31-
{ RelationshipType.Children, Relationships.Children },
32-
{ RelationshipType.Relationship, Relationships.Relationships },
33-
{ RelationshipType.NestedTopics, Relationships.None },
34-
{ RelationshipType.MappedCollection, Relationships.MappedCollections },
35-
{ RelationshipType.IncomingRelationship, Relationships.IncomingRelationships }
29+
var mappings = new Dictionary<CollectionType, Relationships> {
30+
{ CollectionType.Any, Relationships.None },
31+
{ CollectionType.Children, Relationships.Children },
32+
{ CollectionType.Relationship, Relationships.Relationships },
33+
{ CollectionType.NestedTopics, Relationships.None },
34+
{ CollectionType.MappedCollection, Relationships.MappedCollections },
35+
{ CollectionType.IncomingRelationship, Relationships.IncomingRelationships }
3636
};
3737

3838
Mappings = mappings;
@@ -42,7 +42,7 @@ static RelationshipMap() {
4242
/*==========================================================================================================================
4343
| PROPERTY: MAPPINGS
4444
\-------------------------------------------------------------------------------------------------------------------------*/
45-
static internal Dictionary<RelationshipType, Relationships> Mappings { get; }
45+
static internal Dictionary<CollectionType, Relationships> Mappings { get; }
4646

4747
} //Class
4848
} //Namespace

0 commit comments

Comments
 (0)