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

            e.UnsubscribeAll();
            keyToSignal.Remove(key);
            return(true);
        }
Beispiel #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);
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #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));
        }