Skip to content

Mapping: Support IDictionary<> constructor for manual deserialization #99

Description

@JeremyCaney

Optionally provide support for a constructor that accepts an IDictionary<string, string> of key, value pairs representing the values of the Topic.Attributes. This would allow view models to manually bind their primary properties. This would require more development effort upfront, but would potentially be faster than relying on reflection, and especially for commonly used objects.

Implementation

Most of this logic can be implemented in the GetParameterAsync() method by offering special handling for an IDictionary<string, stirng> parameter. In addition, the private MapAsync() overload that creates the initial object will need to be updated to conditionally pass mapAssociationsOnly to SetProperty(), possibly by setting a property on the MappedTopicCacheEntry. Alternatively, the check for the IDictionary<> can be handled in MapAsync(), simplifying how mapAssociationsOnly is set.

Limitations

This would simply support attribute binding, and would leave complex properties (i.e., topic references, parent mappings) and collections (i.e., relationships) to the mapping service—though, of course, each of those associations may include their own IDictionary<> constructor. This is because tracking AssociationTypes and mapping an entire topic graph adds a potentially prohibitive level of of complication for implementers, while also adding a non-trivial amount of logic to the model objects. By contrast, supporting scalar properties addresses the vast majority of needs with minimal implementation overhead.

Metadata

Metadata

Assignees

Labels

Area: MappingRelates to one of the `ITopicMappingService` interfaces or implementations.Priority: 1Severity 1: MinorStatus 5: CompleteTask is considered complete, and ready for deployment.Type: FeatureIntroduces a major area of functionality.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions