using Chernobyl.Event; using System; using System.Collections; using System.Collections.Generic; using Chernobyl.Utility; namespace Chernobyl.Collections.Generic.Event { /// /// An that never changes. This type /// converts an to an /// . /// /// public class StaticEventEnumerable : IEventEnumerable { /// /// Initializes a new instance of the class. /// /// The instance represented by this /// . public StaticEventEnumerable(params T[] enumerable) : this((IEnumerable)enumerable) {} /// /// Initializes a new instance of the class. /// /// The instance represented by this /// . public StaticEventEnumerable(IEnumerable enumerable) { _enumerable = enumerable; } /// /// An event that is raised right after items are added to this list. /// public event EventHandler> ItemsAdded { add { /* event handler not needed. */ } remove { /* event handler not needed. */ } } /// /// An event that is raised right after items are removed from this list. /// public event EventHandler> ItemsRemoved { add { /* event handler not needed. */ } remove { /* event handler not needed. */ } } /// /// Returns an enumerator that iterates through the collection. /// /// /// A that can be used to iterate through /// the collection. /// public IEnumerator GetEnumerator() { return _enumerable.GetEnumerator(); } /// /// Returns an enumerator that iterates through a collection. /// /// /// An object that can be used to iterate /// through the collection. /// IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } /// /// An event that is raised right after items are added to this list. /// event EventHandler IEventEnumerable.ItemsAdded { add { /* event handler not needed. */ } remove { /* event handler not needed. */ } } /// /// An event that is raised right after items are removed from this list. /// event EventHandler IEventEnumerable.ItemsRemoved { add { /* event handler not needed. */ } remove { /* event handler not needed. */ } } /// /// The instance represented by this . /// readonly IEnumerable _enumerable; } /// /// Extensions and utilities for and /// related types. /// public static class StaticEventEnumerableExtensions { /// /// Creates an from an /// . /// /// The type of the elements of source. /// The to create a /// from. /// A that contains elements /// from the input sequence. /// Thrown if /// is null. public static IEventEnumerable ToEventEnumerable(this IEnumerable source) { return new StaticEventEnumerable(source); } } }