Пример #1
0
        protected override bool Act()
        {
            IOutcome <TCollection> oldOutcome  = outcome;
            IOutcome <TCollection> newOutcome  = new Outcome <TCollection>(this);
            IEnumerable <TValue>   newElements = Observer.ObserveInteractions(reactionProcess, newOutcome);

            using (Observer.PauseObservation())
            {
                // if (UsesRecycling)
                // {
                //     //- TODO: Implement this.
                // }

                TCollection newCollection = CreateCollectionFromElements(newElements);

                newOutcome.Value = newCollection;
                outcome          = newOutcome;

                if (AreCollectionsEqual(oldOutcome.Value, newOutcome.Value) == false)
                {
                    SubscriptionManager.Publish(oldOutcome.Value, newOutcome.Value);
                    //- TODO : This gives subscribers access to the internal collection.
                    //         We should return either an IEnumerable or a copy.

                    return(true);
                }

                return(false);
            }
        }
Пример #2
0
        public IEnumerator <TValue> GetEnumerator()
        {
            React();

            IOutcome <TCollection> currentOutcome = outcome; //- Make sure it's the same collection each time

            foreach (TValue element in currentOutcome.Value)
            {
                Observer.NotifyInvolved(currentOutcome);
                yield return(element);
            }
        }