41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
|
|
using DTS.Common.Interface.DASFactory;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace DTS.DASLib.Service
|
|
{
|
|
|
|
// Custom comparer for the IDASCommunication class.
|
|
public class IDASCommunicationEqComparer : IEqualityComparer<IDASCommunication>
|
|
{
|
|
// GainInfo are equal if their Gain is equal.
|
|
public bool Equals(IDASCommunication x, IDASCommunication 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;
|
|
|
|
// Check whether the GainInfos' properties are equal.
|
|
return x.SerialNumber == y.SerialNumber;
|
|
}
|
|
|
|
// If Equals() returns true for a pair of objects,
|
|
// GetHashCode must return the same value for these objects.
|
|
|
|
public int GetHashCode(IDASCommunication idascom)
|
|
{
|
|
// Check whether the object is null.
|
|
if (Object.ReferenceEquals(idascom, null))
|
|
return 0;
|
|
|
|
// Get the hash code for the Gain field.
|
|
return idascom.SerialNumber.GetHashCode();
|
|
}
|
|
}
|
|
}
|