Click or drag to resize
EqualsBuilder Class
A class used to compare object field values inside the Equals method.
Inheritance Hierarchy
SystemObject
  Capgemini.CommonObjectUtilsEqualsBuilder

Namespace: Capgemini.CommonObjectUtils
Assembly: Capgemini.CommonObjectUtils (in Capgemini.CommonObjectUtils.dll) Version: 1.3.0.0
Syntax
public class EqualsBuilder

The EqualsBuilder type exposes the following members.

Constructors
  NameDescription
Public methodEqualsBuilder
Initializes a new instance of the EqualsBuilder class
Top
Methods
  NameDescription
Public methodAppendT(T, T)
Appends two objects that implement the IEquatable interface to the list of values to compare.
Public methodAppendT(T, T, IEqualityComparerT)
Appends two objects to the list of values to compare and compares them using a supplied comparer.
Public methodAppendT(T, T, FuncT, T, Boolean)
Appends two objects to the list values to compare and compares them using a supplied comparison function.
Public methodAppendBase
Appends the result of base.Equals.
Public methodAppendManyT(IEnumerableT, IEnumerableT)
Appends two enumerable objects that contain the same (IEquatable) type to the list of values to compare.
Public methodAppendManyT(IEnumerableT, IEnumerableT, IEqualityComparerT)
Appends two enumerable objects that contain the same type to the list of values to compare.
Public methodAppendManyT(IEnumerableT, IEnumerableT, FuncT, T, Boolean)
Appends two enumerable objects that contain the same type to the list of values to compare.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodReset
Resets the EqualsBuilder so that it can be used again.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyIsEquals
Gets a value indicating whether fields were equal.
Top
Remarks

This class allows you to compare multiple fields in your class in a fluent style.

This is a partial port of the Apache Commons EqualsBuilder class.

Examples
class Foo 
{
    private int field1;
    private int[] field2;

    ...

    public override bool Equals(object obj)
    {
        ...
        MyClass other = obj as MyClass;
        return new EqualsBuilder()
            .Append(field1, other.field1)
            .AppendMany(field2, other.field2)
            .IsEquals;
    }
}
See Also