Beispiel #1
0
        /// <summary>
        /// Returns a rotating enumerator of ResourceDictionary objects that coordinates
        /// with the dispenser object to ensure that no two enumerators are on the same
        /// item. If the dispenser is reset or its collection is changed then the
        /// enumerators are also reset.
        /// </summary>
        /// <param name="predicate">A predicate that returns a value indicating
        /// whether to return an item.</param>
        /// <returns>An enumerator of ResourceDictionaries.</returns>
        public IEnumerator <ResourceDictionary> GetResourceDictionariesWhere(Func <ResourceDictionary, bool> predicate)
        {
            ResourceDictionaryEnumerator enumerator = new ResourceDictionaryEnumerator(this, predicate);

            _ignoreResourceDictionaryDispensedByEnumerator = true;
            try
            {
                foreach (ResourceDictionaryDispensedEventArgs args in _resourceDictionariesDispensed)
                {
                    enumerator.ResourceDictionaryDispenserResourceDictionaryDispensed(this, args);
                }
            }
            finally
            {
                _ignoreResourceDictionaryDispensedByEnumerator = false;
            }

            _resourceDictionaryEnumerators.Add(enumerator);
            return(enumerator);
        }
Beispiel #2
0
 /// <summary>
 /// Unregisters an enumerator so that it can be garbage collected.
 /// </summary>
 /// <param name="enumerator">The enumerator.</param>
 internal void Unregister(ResourceDictionaryEnumerator enumerator)
 {
     _resourceDictionaryEnumerators.Remove(enumerator);
 }