C# Class Gtd.CoreDomain.Tests.CompareObjects

Class that allows comparison of two objects of the same type to each other. Supports classes, lists, arrays, dictionaries, child comparison and more. Source code is taken from http://comparenetobjects.codeplex.com/ All rights are reserved for the author.
Afficher le fichier Open project: beingtheworst/btw-gtd Class Usage Examples

Méthodes publiques

Méthode Description
ClearCache ( ) : void

Reflection properties and fields are cached. By default this cache is cleared automatically after each compare.

Compare ( object object1, object object2 ) : bool

Compare two objects of the same type to each other.

Check the Differences or DifferencesString Properties for the differences. Default MaxDifferences is 1 for performance

CompareObjects ( ) : System

Set up defaults for the comparison

FindDifferences ( object expected, object actual ) : string

Private Methods

Méthode Description
AddBreadCrumb ( string existing, string name, string extra, int index ) : string

Add a breadcrumb to an existing breadcrumb

AddBreadCrumb ( string existing, string name, string extra, string index ) : string

Add a breadcrumb to an existing breadcrumb

Compare ( object object1, object object2, string breadCrumb ) : void

Compare two objects

CompareClass ( object object1, object object2, string breadCrumb ) : void

Compare the properties, fields of a class

CompareEnum ( object object1, object object2, string breadCrumb ) : void

Compare an enumeration

CompareIDictionary ( object object1, object object2, string breadCrumb ) : void

Compare a dictionary

CompareIList ( object object1, object object2, string breadCrumb ) : void

Compare an array or something that implements IList

CompareIndexer ( PropertyInfo info, object object1, object object2, string breadCrumb ) : void
ComparePointer ( object object1, object object2, string breadCrumb ) : void

Compare a pointer struct

CompareSimpleType ( object object1, object object2, string breadCrumb ) : void

Compare a simple type

CompareStruct ( object object1, object object2, string breadCrumb ) : void

Compare a struct

CompareTimespan ( object object1, object object2, string breadCrumb ) : void

Compare a timespan struct

GetFieldInfo ( Type type ) : IEnumerable
GetPropertyInfo ( Type type ) : IEnumerable
IgnoredByAttribute ( Type type ) : bool

Check if any type has attributes that should be bypassed

IsArray ( Type t ) : bool
IsChildType ( Type t ) : bool
IsClass ( Type t ) : bool
IsEnum ( Type t ) : bool
IsIDictionary ( Type t ) : bool
IsIList ( Type t ) : bool
IsPointer ( Type t ) : bool
IsSimpleType ( Type t ) : bool
IsStruct ( Type t ) : bool
IsTimespan ( Type t ) : bool
IsValidIndexer ( PropertyInfo info, string breadCrumb ) : bool
PerformCompareFields ( Type t1, object object1, object object2, string breadCrumb ) : void

Compare the fields of a class

PerformCompareProperties ( Type t1, object object1, object object2, string breadCrumb ) : void

Compare the properties of a class

ValidStructSubType ( Type t ) : bool
cStr ( object obj ) : string

Convert an object to a nicely formatted string

Method Details

ClearCache() public méthode

Reflection properties and fields are cached. By default this cache is cleared automatically after each compare.
public ClearCache ( ) : void
Résultat void

Compare() public méthode

Compare two objects of the same type to each other.
Check the Differences or DifferencesString Properties for the differences. Default MaxDifferences is 1 for performance
public Compare ( object object1, object object2 ) : bool
object1 object
object2 object
Résultat bool

CompareObjects() public méthode

Set up defaults for the comparison
public CompareObjects ( ) : System
Résultat System

FindDifferences() public static méthode

public static FindDifferences ( object expected, object actual ) : string
expected object
actual object
Résultat string