예제 #1
0
        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 EventTypeEnum.None:
                break;

            case EventTypeEnum.Changed:
                return(true);

            case EventTypeEnum.Cleared:
                if (Args is ClearedRangeEventArgs)
                {
                    ClearedRangeEventArgs a = Args as ClearedRangeEventArgs, o = otherEvent.Args as ClearedRangeEventArgs;
                    if (o == null)
                    {
                        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 EventTypeEnum.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 EventTypeEnum.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 EventTypeEnum.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 EventTypeEnum.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);
        }
예제 #2
0
 public void Add(CollectionEvent <T> e)
 {
     happened.Add(e);
 }