CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Equality Comparers

193 Views
Copy Code Show/Hide Line Numbers
new PersistenceSpecification<Component>(session, new ComponentEqualityComparer())
 
public class ComponentEqualityComparer : IEqualityComparer
{
    #region IEqualityComparer Members
 
    public bool Equals(object x, object y)
    {
        if (x == null || y == null)
        {
            return false;
        }
 
        if (x is DateTime && y is DateTime)
        {
            return true;
        }
 
        if (x is ComponentInstance && y is ComponentInstance)
        {
            return ((ComponentInstance)x).SubscriptionId == ((ComponentInstance)y).SubscriptionId;
        }
 
        return x.Equals(y);
    }
 
    public int GetHashCode(object obj)
    {
        throw new NotImplementedException();
    }
 
    #endregion
}
by Mikael Henriksson
  October 13, 2009 @ 3:15am
Tags:

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate