I am processing zip files using queue. So whenever a new zip file arrives to the specified path, file_info will be added to queue using
fileQueue.Enqueue(IFile);
Now I should add the File to queue only if it does not exist. I tried to implement IEqualityComparer<T>
interface and the
public bool Equals(T x, T y)
{
object xValue = _propertyInfo.GetValue(x, null);
object yValue = _propertyInfo.GetValue(y, null);
return xValue.Equals(yValue);
}
and
public int GetHashCode(T obj)
{
object propertyValue = _propertyInfo.GetValue(obj, null);
if (propertyValue == null)
return 0;
else
return propertyValue.GetHashCode();
}
I have an interface to get the fileInfo
public interface IFile
{
string FilePath { get; set; }
}
Another queue object
public Queue<IFile> fileQueue = new Queue<IFile>();
Can anyone please suggest how to check if the file already exists in the queue before adding it to the queue again. Thanks you very much in advance.