Skip to content

Commit 2f482b1

Browse files
committed
Migrate mapping services to use ItemMetadata.Configuration
The `TopicMappingService` and `ReverseTopicMappingService` (and, by extension, the `BindingModelValidator`) have been updated to pull the `ItemConfiguration` from `ItemMetadata` (or `PropertyMetadata`) (74cb817) instead of constructing a new version directly. This takes advantage of the caching of `TypeAccessor` and `ParameterMetadata`, thus ensuring the configuration data only needs to be assessed once per item. This loses access to the `attributePrefix` state data, and thus temporarily breaks the `[MapToParent]` functionality. In a future commit, we'll update the `TopicMappingService` and `ReverseTopicMappingService` to relay that internally, and reference it as needed. This may also temporarily break some references that were relying on specific properties of `PropertyConfiguration`, namely `MemberAccessor`; that will be resolved in a subsequent commit, when we begin relaying `MemberAccessor` instead of `PropertyConfiguration`.
1 parent 3a16de4 commit 2f482b1

4 files changed

Lines changed: 4 additions & 7 deletions

File tree

OnTopic/Mapping/Internal/PropertyConfiguration.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ internal class PropertyConfiguration: ItemConfiguration {
4141
/// <param name="memberAccessor">
4242
/// The <see cref="MemberAccessor"/> instance to check for <see cref="Attribute"/> values.
4343
/// </param>
44-
/// <param name="attributePrefix">The prefix to apply to the attributes.</param>
45-
internal PropertyConfiguration(MemberAccessor memberAccessor, string? attributePrefix = ""):
46-
base(memberAccessor, memberAccessor.Name, attributePrefix)
47-
{
44+
internal PropertyConfiguration(MemberAccessor memberAccessor): base(memberAccessor) {
4845
MemberAccessor = memberAccessor;
4946
}
5047

OnTopic/Mapping/Reverse/BindingModelValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ static internal void ValidateProperty(
148148
/*------------------------------------------------------------------------------------------------------------------------
149149
| Define variables
150150
\-----------------------------------------------------------------------------------------------------------------------*/
151-
var configuration = new PropertyConfiguration(propertyAccessor, attributePrefix);
152151
var compositeAttributeKey = configuration.AttributeKey;
152+
var configuration = propertyAccessor.Configuration;
153153
var attributeDescriptor = contentTypeDescriptor.AttributeDescriptors.GetValue(compositeAttributeKey);
154154
var childCollections = new[] { CollectionType.Children, CollectionType.NestedTopics };
155155
var relationships = new[] { CollectionType.Relationship, CollectionType.IncomingRelationship };

OnTopic/Mapping/Reverse/ReverseTopicMappingService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private async Task SetPropertyAsync(
240240
/*------------------------------------------------------------------------------------------------------------------------
241241
| Establish per-property variables
242242
\-----------------------------------------------------------------------------------------------------------------------*/
243-
var configuration = new PropertyConfiguration(propertyAccessor, attributePrefix);
243+
var configuration = memberAccessor.Configuration;
244244
var contentTypeDescriptor = _contentTypeDescriptors.GetValue(target.ContentType);
245245
var compositeAttributeKey = configuration.AttributeKey;
246246

OnTopic/Mapping/TopicMappingService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ private async Task<object> MapAsync(
392392
/*------------------------------------------------------------------------------------------------------------------------
393393
| Establish per-property variables
394394
\-----------------------------------------------------------------------------------------------------------------------*/
395-
var configuration = new ItemConfiguration(parameter, parameter.Name, attributePrefix);
395+
var configuration = parameter.Configuration;
396396

397397
/*------------------------------------------------------------------------------------------------------------------------
398398
| Bypass if mapping is disabled

0 commit comments

Comments
 (0)