예제 #1
0
        public void Add(UpdateContextSearchData searchData)
        {
            var key = searchData.Key;

            if (_dict.TryRemove(key, out var prevData))
            {
                prevData.CurrentUpdateContext.HiddenContext().UpdateProcessingAbortedSource.Cancel();
            }
            _dict[searchData.Key] = searchData;
        }
예제 #2
0
        /// <summary>
        /// Return removed object or null.
        /// </summary>
        public UpdateContextSearchData?TryRemove(long chatId, int botId)
        {
            var key = UpdateContextSearchData.CreateKey(chatId, botId);

            if (_dict.TryRemove(key, out var val))
            {
                return(val);
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// Return value or null.
        /// </summary>
        public UpdateContextSearchData?TryFind(long chatId, int botId)
        {
            RemoveDisposed();
            var key = UpdateContextSearchData.CreateKey(chatId, botId);

            if (_dict.TryGetValue(key, out var val))
            {
                return(val);
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
        public bool Contains(long chatId, int botId)
        {
            var key = UpdateContextSearchData.CreateKey(chatId, botId);

            return(_dict.ContainsKey(key));
        }