Implement OnTopic 5.2.0 `AttributeDictionary` constructors
Closed this issue · 1 comments
In the preview release of OnTopic 5.2.0, the AttributeDictionary
provides a faster way to establish local property values during the mapping process than relying on reflection. When a constructor accepting an AttributeDictionary
as its only parameter is exposed, the TopicMappingService
will pass a lightweight AttributeDictionary
containing key/value pairs of all attributes from the current topic and any BaseTopic
references. This puts the onus on the constructor to set these values, and then bypasses subsequent processing of them in the TopicMappingService
. When there are multiple mapped attributes, this proves to be significantly faster than relying on reflection to set each property value.
This is useful for the OnTopic Editor, as each call relies on mapping deep trees of ContentTypeDescriptorViewModel
, AttributeDescriptorViewModel
, and derived types, many of which have quite a few scalar properties mapping directly to topic attributes. As such, they are a prime candidate for this improvement.
It's worth being aware that the TopicMappingService
is not guaranteed to call this constructor if it exists, and thus it should not be dependent upon to e.g. set defaults. Instead, an empty constructor should also be provided. This is because the AttributeDictionary
overload introduces some upfront cost, and so the TopicMappingService
only implements it if there are enough source attribute values and target scalar properties that don't map back to properties on the source Topic
. In the case of the OnTopic Editor, it's very likely that every instance will call the AttributeDictionary
, due to how many required attributes are on the base AttributeDescriptorViewModel
, but this should not be relied upon.
This was resolved with e3a1b77.