An event aggregator.
Inheritance: IEventBus, IDisposable
Ejemplo n.º 1
0
        /// <summary>Retrieves a singleton instance of an event-bus with the given key.</summary>
        /// <param name="key">The unique identifier of the event-bus.</param>
        public static IEventBus GetSingleton(object key)
        {
            // Look for existing event-bus.
            IEventBus bus = Helper.Collection.First(singletons, delegate(object o)
                                                                   {
                                                                       return ((IEventBus)o).Key == key;
                                                                   }) as IEventBus;
            if (bus != null) return bus;

            // Create and store a new instance of the event-bus.
            bus = new EventBus(key);
            singletons.Add(bus);

            // Finish up.
            return bus;
        }