예제 #1
0
        private static bool UnsubscribeAndRemove(ScopeKey key)
        {
            if (!keyToSignal.TryGetValue(key, out var e))
            {
                return(false);
            }

            e.UnsubscribeAll();
            keyToSignal.Remove(key);
            return(true);
        }
예제 #2
0
        private static T GetOrCreateSignal <T>(ScopeKey key) where T : SignalBase, new()
        {
            if (!keyToSignal.TryGetValue(key, out var e))
            {
                keyToSignal[key] = e = new T {
                    Name = key.Key
                }
            }
            ;

            return((T)e);
        }
예제 #3
0
        /// <summary>
        /// Unsubscribe all callbacks and remove Signal from cache
        /// </summary>
        public static bool UnsubscribeAndRemoveSignal <T1, T2>(string scopeKey)
        {
            var key = new ScopeKey(typeof(Signal <T1, T2>), scopeKey);

            return(UnsubscribeAndRemove(key));
        }
예제 #4
0
        /// <summary>Get State by Key</summary>
        public static State <T, TK> State <T, TK>(string scopeKey)
        {
            var key = new ScopeKey(typeof(State <T, TK>), scopeKey);

            return(GetOrCreateSignal <State <T, TK> >(key));
        }
예제 #5
0
        /// <summary>Get Signal by Key</summary>
        public static Signal <T1, T2> Signal <T1, T2>(string scopeKey)
        {
            var key = new ScopeKey(typeof(Signal <T1, T2>), scopeKey);

            return(GetOrCreateSignal <Signal <T1, T2> >(key));
        }
예제 #6
0
        /// <summary>Get Signal by Key</summary>
        public static Signal Signal(string scopeKey)
        {
            var key = new ScopeKey(typeof(Signal), scopeKey);

            return(GetOrCreateSignal <Signal>(key));
        }
예제 #7
0
        /// <summary>
        /// Unsubscribe all callbacks and remove State from cache
        /// </summary>
        public static bool UnsubscribeAndRemoveState <T>(string scopeKey)
        {
            var key = new ScopeKey(typeof(State <T>), scopeKey);

            return(UnsubscribeAndRemove(key));
        }