public bool Equals(CollectionEvent <T> otherEvent, SCG.IEqualityComparer <T> itemequalityComparer) { if (otherEvent == null || Act != otherEvent.Act || !object.ReferenceEquals(Sender, otherEvent.Sender)) { return(false); } switch (Act) { case EventType.None: break; case EventType.Changed: return(true); case EventType.Cleared: if (Args is ClearedRangeEventArgs) { ClearedRangeEventArgs a = Args as ClearedRangeEventArgs; if (!(otherEvent.Args is ClearedRangeEventArgs o)) { return(false); } return(a.Full == o.Full && a.Start == o.Start && a.Count == o.Count); } else { if (otherEvent.Args is ClearedRangeEventArgs) { return(false); } ClearedEventArgs a = Args as ClearedEventArgs, o = otherEvent.Args as ClearedEventArgs; return(a.Full == o.Full && a.Count == o.Count); } case EventType.Added: { ItemCountEventArgs <T> a = Args as ItemCountEventArgs <T>, o = otherEvent.Args as ItemCountEventArgs <T>; return(itemequalityComparer.Equals(a.Item, o.Item) && a.Count == o.Count); } case EventType.Removed: { ItemCountEventArgs <T> a = Args as ItemCountEventArgs <T>, o = otherEvent.Args as ItemCountEventArgs <T>; return(itemequalityComparer.Equals(a.Item, o.Item) && a.Count == o.Count); } case EventType.Inserted: { ItemAtEventArgs <T> a = Args as ItemAtEventArgs <T>, o = otherEvent.Args as ItemAtEventArgs <T>; return(a.Index == o.Index && itemequalityComparer.Equals(a.Item, o.Item)); } case EventType.RemovedAt: { ItemAtEventArgs <T> a = Args as ItemAtEventArgs <T>, o = otherEvent.Args as ItemAtEventArgs <T>; return(a.Index == o.Index && itemequalityComparer.Equals(a.Item, o.Item)); } } throw new ApplicationException("Illegal Action: " + Act); }
public void Add(CollectionEvent <T> e) { happened.Add(e); }