Skip to content

tobiaswuerth/Object-Content-Comparator

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
src
 
 
 
 
 
 
 
 

Object-Content-Comparator

Compare objects of any type based on their property values.

Download

.net core v2.0
.net framework v4.6
Download latest release here (pre-release v0.1)

How does it work?

The object is serialized into JSON (properties can be labled using the attributes [JsonProperty] and [JsonIgnore]) which then is hashed using the SHA512 Algorithm. The objects are compared by comparing their hashes which does not guarantee that every content generates a unique hash ... but pretty much. Click here to find out more.

Dependencies

Newtonsoft Json.NET Nuget package

Usage

var obj1 = new MyStatelessClass();
var obj2 = new MyStatelessClass();

Comparator.AreEqual(obj1, obj2);
>>> true

Comparator.AreEqual(15, "15"); // this is because string "15" and integer 15 are not considered equal
>>> false

Comparator.AreEqual(DateTime.MinValue, DateTime.Parse("01/01/0001 00:00:00"));
>>> true

About

Compare any objects based on their properties and property contents

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages