static CollectionChangedEventManager()
        {
            // This will create a weak event manager for this class.
            Type weakEventManagerType = typeof(CollectionChangedEventManager);
            CollectionChangedEventManager currentManager = WeakEventManager.GetCurrentManager(weakEventManagerType) as CollectionChangedEventManager;

            CollectionChangedEventManager.currentManager = new CollectionChangedEventManager();
            WeakEventManager.SetCurrentManager(weakEventManagerType, CollectionChangedEventManager.currentManager);
        }
        static LoadedWeakEventManager GetCurrentManager()
        {
            var mt = typeof(LoadedWeakEventManager);

            var manager = ( LoadedWeakEventManager )WeakEventManager.GetCurrentManager(mt);

            if (manager == null)
            {
                manager = new LoadedWeakEventManager();
                WeakEventManager.SetCurrentManager(mt, manager);
            }

            return(manager);
        }
        static MonitorChangedWeakEventManager GetCurrentManager()
        {
            var mt = typeof(MonitorChangedWeakEventManager);

            var manager = ( MonitorChangedWeakEventManager )WeakEventManager.GetCurrentManager(mt);

            if (manager == null)
            {
                manager = new MonitorChangedWeakEventManager();
                WeakEventManager.SetCurrentManager(mt, manager);
            }

            return(manager);
        }
Exemplo n.º 4
0
        protected static T GetManager <T>()
            where T : RoutedEventManagerBase, new()
        {
            var manager_type = typeof(T);
            var manager      = WeakEventManager.GetCurrentManager(manager_type) as T;

            if (manager == null)
            {
                manager = new T();
                WeakEventManager.SetCurrentManager(manager_type, manager);
            }

            return(manager);
        }