private List<IEvent> removeRedundantEvents(List<IEvent> events)
        {
            List<IEvent> returnList = new List<IEvent>();

            ListState finalState = new ListState();

            //Load the normal final state of all the events.
            finalState.LoadList(allPreviousEvents);
            finalState.LoadList(events);

            foreach (IEvent @event in events)
            {
                if (@event == null)
                    break;
                returnList.Add(@event);

                ListState checkState = new ListState();
                checkState.LoadList(allPreviousEvents);
                // Load a stat without the current event.
                IEnumerable<IEvent> without = events.Where(e => !(e.Equals(@event)));
                List<IEvent> withoutList = without.ToList();
                checkState.LoadList(without.ToList());

                // Check if it is the same as the final state.
                if (checkState.Equals(finalState))
                {
                    Debug.WriteLine("Redundant operation found!!!");
                    returnList.Remove(@event);
                }
            }

            return returnList;
        }
コード例 #2
0
        private ListState calculateOfflineListState()
        {
            ListState newState = new ListState();

            newState.LoadList(allPreviousEvents);
            newState.LoadList(generatedEvents);
            return newState;
        }