Giter Club home page Giter Club logo

objectequality's Introduction

ObjectEquality v1.0.7

A open-source library to compare whether two object are same

Support TYPE

  • Value Type
  • Class
  • Generic Collection(Strict/Loose)
  • Array(Strict/Loose)
  • Tuple
  • Struct

How to use it?

Check Value-Type object

Example:

var a = 1;
var b = 2;

var objectEquality = new ObjectEquality();
objectEquality.IsEqual(a,b);

Check Array object

Example:

var a = new int[]{1,2,3};
var b = new int[]{1,2,3};
var c = new int[]{1,2,4};

var objectEquality = new ObjectEquality();
objectEquality.IsEqual(a,b); //true
objectEquality.IsEqual(a,c); //false

Check Array object(Loose mode)

You can set the ArrayEqualityMode of ObjectEqualityOptions as Loose to enable the loose mode

Example

var a = new int[] { 1, 2, 3 };
var b = new int[] { 2, 1, 3 };
var c = new int[] { 1, 1, 3 };

ObjectEqualityOptions.Current.ArrayEqualityMode = ArrayEqualityMode.Loose;
var objectEquality = new ObjectEquality();
objectEquality.IsEqual(a,b); //true
objectEquality.IsEqual(a,c); //false

Check two dimension array

Example


var arrayA = new int[2, 3] { { 1, 1, 1 }, { 2, 2, 2 } };
var arrayB = new int[2, 3] { { 1, 1, 1 }, { 2, 2, 2 } };
var arrayC = new int[2, 3] { { 1, 1, 2 }, { 2, 2, 2 } };

arrayA.IsEqual(arrayB); //true
arrayA.IsEqual(arrayC); //false

We only support strict mode for two dimension array.

Check Simple Class object

public class SimpleClass
{
    public int Id { get; set; }

    public string Name { get; set; }
}

var a = new SimpleClass
{
    Id = 1,
    Name = "A"
};

var b = new SimpleClass
{
    Id = 1,
    Name = "A"
};

var objectEquality = new ObjectEquality();
objectEquality.IsEqual(a,b); //true

objectequality's People

Contributors

lamondlu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.