- internal class LocalFileComparer:EqualityComparer<CloudAction>
- {
- public override bool Equals(CloudAction x, CloudAction y)
- {
- if (x.Action != y.Action)
- return false;
- if (x.LocalFile != null && y.LocalFile != null && !x.LocalFile.FullName.Equals(y.LocalFile.FullName))
- return false;
- if (x.CloudFile != null && y.CloudFile != null )
- {
- if (x.CloudFile.Hash == null & y.CloudFile.Hash != null)
- return false;
- if (x.CloudFile.Hash != null & y.CloudFile.Hash == null)
- return false;
- if (x.CloudFile.Hash == null & y.CloudFile.Hash == null)
- return (x.CloudFile.Name == y.CloudFile.Name);
- if (!x.CloudFile.Hash.Equals(y.CloudFile.Hash))
- return false;
- }
- if (x.CloudFile == null ^ y.CloudFile == null ||
- x.LocalFile == null ^ y.LocalFile == null)
- return false;
- return true;
- }
-
- public override int GetHashCode(CloudAction obj)
- {
- var hash1 = (obj.LocalFile == null) ? int.MaxValue : obj.LocalFile.FullName.GetHashCode();
- var hash2 = (obj.CloudFile == null) ? int.MaxValue : (obj.CloudFile.Hash ?? obj.CloudFile.Name??"").GetHashCode();
- var hash3 = obj.Action.GetHashCode();
- return hash1 ^ hash2 & hash3;
- }
- }
-
- private Timer timer;