PermissionComparer.cs
950 Bytes
using HHECS.Model.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HHECS.Model.ClassComparer
{
public class PermissionComparer : IEqualityComparer<Permission>
{
public bool Equals(Permission x, Permission y)
{
//Check whether the compared objects reference the same data.
if (Object.ReferenceEquals(x, y)) return true;
//Check whether any of the compared objects is null.
if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
return false;
return x.Id == y.Id;
}
public int GetHashCode(Permission obj)
{
//Check whether the object is null
if (Object.ReferenceEquals(obj, null)) return 0;
//Calculate the hash code for the product.
return obj.Id;
}
}
}