コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #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);
        }