示例#1
0
        /// <summary>
        ///     设置缓存
        /// </summary>
        public static void SetCache(Type key, ICustomInterceptor[] interceptors)
        {
            if (interceptors == null || interceptors.Length == 0)
            {
                throw new ArgumentNullException(nameof(interceptors));
            }
            var cache = new CustomInterceptorCacheManager(key).GetValue();

            if (cache == null)
            {
                var set = new HashSet <ICustomInterceptor>();
                foreach (var item in interceptors)
                {
                    set.Add(item);
                }
                Update(key, set);
            }
            else
            {
                foreach (var item in interceptors)
                {
                    ((HashSet <ICustomInterceptor>)cache).Add(item);
                }
            }
        }
示例#2
0
        /// <summary>
        ///     获取缓存
        /// </summary>
        public static IEnumerable <ICustomInterceptor> GetCache(Type key)
        {
            var cache = new CustomInterceptorCacheManager(key).GetValue();

            return(cache ?? ArrayExtends.Empty <ICustomInterceptor>());
        }