예제 #1
0
        /// <summary>
        /// 添加过滤器
        /// </summary>
        /// <param name="wordFilterTypeId">过滤器类型</param>
        /// <param name="wordDict">敏感词集合</param>
        /// <returns>key-待处理字符,value-用来替换的字符</returns>
        public static void Add(int wordFilterTypeId, Dictionary <string, string> wordDict)
        {
            if (wordDict == null)
            {
                return;
            }

            registeredFilters[wordFilterTypeId] = new WordFilter(wordDict);
        }
예제 #2
0
        /// <summary>
        /// 过滤器实例
        /// </summary>
        /// <param name="filterTypeId">过滤器类型Id</param>
        public static WordFilter Instance(int filterTypeId)
        {
            if (!registeredFilters.ContainsKey(filterTypeId) || registeredFilters[filterTypeId] == null)
            {
                lock (lockObject)
                {
                    if (!registeredFilters.ContainsKey(filterTypeId) || registeredFilters[filterTypeId] == null)
                    {
                        registeredFilters[filterTypeId] = new WordFilter(new Dictionary <string, string>());
                    }
                }
            }

            return(registeredFilters[filterTypeId]);
        }
예제 #3
0
        /// <summary>
        /// 添加过滤器
        /// </summary>
        /// <param name="wordFilterTypeId">过滤器类型</param>
        /// <param name="wordDict">敏感词集合</param>
        /// <returns>key-待处理字符,value-用来替换的字符</returns>
        public static void Add(int wordFilterTypeId, Dictionary<string, string> wordDict)
        {
            if (wordDict == null)
                return;

            registeredFilters[wordFilterTypeId] = new WordFilter(wordDict);
        }
예제 #4
0
        /// <summary>
        /// 过滤器实例
        /// </summary>
        /// <param name="filterTypeId">过滤器类型Id</param>
        public static WordFilter Instance(int filterTypeId)
        {
            if (!registeredFilters.ContainsKey(filterTypeId) || registeredFilters[filterTypeId] == null)
            {
                lock (lockObject)
                {
                    if (!registeredFilters.ContainsKey(filterTypeId) || registeredFilters[filterTypeId] == null)
                    {
                        registeredFilters[filterTypeId] = new WordFilter(new Dictionary<string, string>());
                    }
                }
            }

            return registeredFilters[filterTypeId];
        }