Open.Core.EventBus.GetSingleton C# (CSharp) Method

GetSingleton() public static method

Retrieves a singleton instance of an event-bus with the given key.
public static GetSingleton ( object key ) : IEventBus
key object The unique identifier of the event-bus.
return IEventBus
        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;
        }
        #endregion