| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
The OnTopic.Data.Transfer assembly defines a data transfer object to act as an intermediary between the Topic class and serialization targets (such as JSON) used for web services.
Technically, the Topic class—as well as its dependents—could be directly serialized. Because of the complexity of these classes, however, that would introduce a lot of clutter and complexity to the JSON format. This could be avoided, but would almost certainly require not only careful annotation of the entity classes, but quite possibly the introduction of custom converters. Further, even were this done, it wouldn't provide an opportunity to e.g. merge deserialized topics with an existing topic graph. Providing intermediary data transfer objects which offers a simplified data structure for modeling a topic, as well as extension methods for converting them to and from Topic classes addresses this problem.
The OnTopic.Data.Transfer assembly includes three basic data transfer classes along side a custom collection class:
The OnTopic.Data.Transfer.Interchange namespace includes extension methods for the OnTopic.Topic entity which allow a TopicData graph to be exported from a Topic graph—or imported back into one:
Optionally, the Topic.Export() extension method will accept an ExportOptions object as argument in order to fine-tune the business logic for the export. This includes the following options:
Optionally, the Topic.Import() extension method will accept an ImportOptions object as argument in order to fine-tune the business logic for the import. Most notably, this includes a Strategy property for setting the ImportStrategy enum, which includes the following options:
In addition to the Strategy property, the ImportOptions also allows the behavior to be fine-tuned, if further control is required:
Finally, an import strategy can be defined for how to handle the LastModified and LastModifiedBy attributes during import by using the LastModifiedImportStrategy enum. This supports:
When using a LastModifiedImportStrategy, there are three properties that should be defined on the ImportOptions object:
Serializing TopicData graphs to JSON and deserializing JSON back to a TopicData graph operates exactly like it would for any other C# objects.
var topicData = topic.Export(); var json = JsonSerializer.Serialize(topicData);
var topicData = JsonSerializer.Deserialize<TopicData>(json);
Installation can be performed by providing a <PackageReference /> to the OnTopic.Data.Transfer NuGet package.
<Project Sdk="Microsoft.NET.Sdk.Web">
…
<ItemGroup>
<PackageReference Include="OnTopic.Data.Transfer" Version="2.0.0" />
</ItemGroup>
</Project>Note: This package is currently only available on Ignia's private NuGet repository. For access, please contact Ignia.
| Back | FazBrowse Home | New Git URL |