/// <summary> /// Returns a rotating enumerator of Style objects that coordinates with /// the style dispenser object to ensure that no two enumerators are /// currently on the same style if possible. If the style /// dispenser is reset or its collection of styles is changed then /// the enumerators will also be reset. /// </summary> /// <param name="stylePredicate">A predicate that returns a value /// indicating whether to return a style.</param> /// <returns>An enumerator of styles.</returns> public IEnumerator <Style> GetStylesWhere(Func <Style, bool> stylePredicate) { StyleEnumerator enumerator = new StyleEnumerator(this, stylePredicate); _ignoreStyleDispensedByEnumerator = true; try { foreach (StyleDispensedEventArgs args in _stylesDispensed) { enumerator.StyleDispenserStyleDispensed(this, args); } } finally { _ignoreStyleDispensedByEnumerator = false; } _styleEnumerators.Add(enumerator); return(enumerator); }
/// <summary> /// Unregisters a style enumerator so that it can be garbage collected. /// </summary> /// <param name="enumerator">The style enumerator.</param> internal void Unregister(StyleEnumerator enumerator) { _styleEnumerators.Remove(enumerator); }