public int GetHashCode(LastWriteWinsElement <T> obj)
 {
     unchecked
     {
         return((EqualityComparer <T> .Default.GetHashCode(obj.Element) * 397) ^ obj.Timestamp.GetHashCode());
     }
 }
Esempio n. 2
0
        private void AddToSet(
            IDictionary <T, HashSet <LastWriteWinsElement <T> > > set,
            T element,
            DateTime?timestamp = null)
        {
            timestamp = timestamp ?? DateTime.UtcNow;
            var elementWithTimestamp = new LastWriteWinsElement <T>(element, timestamp.Value);

            if (set.ContainsKey(element))
            {
                set[element].Add(elementWithTimestamp);
            }
            else
            {
                set[element] = new HashSet <LastWriteWinsElement <T> >(_lastWriteWinsElementComparer)
                {
                    elementWithTimestamp
                };
            }
        }
 public bool Equals(LastWriteWinsElement <T> x, LastWriteWinsElement <T> y)
 {
     if (ReferenceEquals(x, y))
     {
         return(true);
     }
     if (ReferenceEquals(x, null))
     {
         return(false);
     }
     if (ReferenceEquals(y, null))
     {
         return(false);
     }
     if (x.GetType() != y.GetType())
     {
         return(false);
     }
     return(_elementComparer.Equals(x.Element, y.Element) && x.Timestamp.Equals(y.Timestamp));
 }