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.
Optionally provide support for a constructor that accepts an
IDictionary<string, string>ofkey,valuepairs representing the values of theTopic.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 anIDictionary<string, stirng>parameter. In addition, the privateMapAsync()overload that creates the initial object will need to be updated to conditionally passmapAssociationsOnlytoSetProperty(), possibly by setting a property on theMappedTopicCacheEntry. Alternatively, the check for theIDictionary<>can be handled inMapAsync(), simplifying howmapAssociationsOnlyis 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 trackingAssociationTypesand 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.