ObjectDelta 9.0.1
dotnet add package ObjectDelta --version 9.0.1
NuGet\Install-Package ObjectDelta -Version 9.0.1
<PackageReference Include="ObjectDelta" Version="9.0.1" />
<PackageVersion Include="ObjectDelta" Version="9.0.1" />
<PackageReference Include="ObjectDelta" />
paket add ObjectDelta --version 9.0.1
#r "nuget: ObjectDelta, 9.0.1"
#:package ObjectDelta@9.0.1
#addin nuget:?package=ObjectDelta&version=9.0.1
#tool nuget:?package=ObjectDelta&version=9.0.1
ObjectDelta
A libary that creates a delta of two object instances.
The library is inspired by a blog post of Daniel Wertheim about
producing a delta of two objects of the same type using the library Structurizer.
Unfortunately Structurizer will not provide index information
for properties with a null value, the property of a collection and for null collection items.
This information is needed to be able to record object changes from null to a value and vice versa.
I decided to create a library based on Structurizer that fits
my needs for the delta creation.
Usage
Customer first = new Customer
{
FirstName = "Sherlock",
LastName = "Olmes",
Address = new Address
{
Street = "Baker Street",
Number = "900",
Zip = "NW1",
City = "London",
Country = "England"
},
Tags = new string[] { "detective", "addict" }
};
Customer second = new Customer
{
FirstName = "Sherlock",
LastName = "Holmes",
Address = new Address
{
Street = "Baker Street",
Number = "221b",
Zip = "NW1",
City = "London",
Country = "England"
},
Tags = new string[] { "detective", "genius", "addict" }
};
ObjectDelta<Customer> result = ObjectComparer.Compare(first, second);
The resulting ObjectDelta<Customer> provides a flat list containing the deltas for every property,
inclusing nested properties of complex types (like the Address) and colleection items.
The output of ToString() of the result of operation above:
LastName (Olmes => Holmes)
Address (ConsoleApp1.Address => ConsoleApp1.Address)
Address.Number (900 => 221b)
Tags (System.String[] => System.String[])
Tags[1] (addict => genius)
Tags[2] (null => addict)
Structure
This creates a flat structure for types and a flat key-value structure for instances.
Usage
If you just ant to create the schema of a type just pass it to the IStructureBuilder.
IStructureBuilder builder = new StructureBuilder();
Structure structure = builder.CreateStructure<Customer>();
Console.WriteLine(structure.Schema);
This will result in a flat list of the property structure of the type Customer.
FirstName
LastName
Address
Address.Street
Address.Number
Address.Zip
Address.City
Address.Country
Tags
To create the schema and accessors for the values of an instance pass the instance to the IStructureBuilder.
Customer customer = new Customer
{
FirstName = "Sherlock",
LastName = "Holmes",
Address = new Address
{
Street = "Baker Street",
Number = "221b",
Zip = "NW1",
City = "London",
Country = "England"
},
Tags = new string[] { "detective", "addict" }
};
IStructureBuilder builder = new StructureBuilder();
Structure structure = builder.CreateStructure(customer);
Console.WriteLine(structure.Indices);
This will result in a flat list of the property values in the given instance of type Customer.
FirstName = "Sherlock"
LastName = "Holmes"
Address = "ConsoleApp1.Address"
Address.Street = "Baker Street"
Address.Number = "221b"
Address.Zip = "NW1"
Address.City = "London"
Address.Country = "England"
Tags = "System.String[]"
Tags[0] = "detective"
Tags[1] = "addict"
Acknowledgement
Most of the terminology and code structure of the library comes from the libary Structurizer
by Daniel Wertheim. This is basically a fork of his work which I bent to my needs, f.e. the need
to support null values in index values and some other fixes and tweaks. I completely remove the configuration part and added the
ability to just get the schema of a type. The library this work is based on is licensed under the MIT license and so it this library.
References
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.1 | 1,086 | 3/3/2025 |
| 9.0.0 | 708 | 11/14/2024 |
| 8.0.5 | 182 | 11/1/2024 |
| 8.0.4 | 188 | 7/9/2024 |
| 8.0.3 | 180 | 6/2/2024 |
| 8.0.2 | 1,202 | 3/19/2024 |
| 8.0.1 | 1,304 | 11/24/2023 |
| 8.0.0 | 317 | 11/16/2023 |
| 2.1.0 | 1,443 | 1/18/2023 |
| 2.0.0 | 951 | 11/19/2022 |
| 1.0.2 | 3,127 | 6/7/2022 |
| 1.0.1 | 549 | 6/3/2022 |
| 1.0.0 | 1,956 | 4/18/2022 |