Ejemplo n.º 1
0
        /// <summary>
        /// 引发 <see cref="CacheResolve"/> 事件。
        /// </summary>
        /// <typeparam name="TKey">缓冲对象的键的类型。</typeparam>
        /// <typeparam name="TValue">缓冲对象的类型。</typeparam>
        /// <param name="key">缓冲池的键。</param>
        /// <param name="exception">配置错误异常。</param>
        private static ICache <TKey, TValue> OnCacheResolve <TKey, TValue>(string key,
                                                                           ConfigurationErrorsException exception)
        {
            EventHandler <CacheResolveEventArgs> events = CacheResolve;

            if (events != null)
            {
                CacheResolveEventArgs args = new CacheResolveEventArgs(
                    key, typeof(TKey), typeof(TValue), exception);
                events(null, args);
                return(args.CacheObject as ICache <TKey, TValue>);
            }
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 引发 <see cref="CacheResolve"/> 事件。
        /// </summary>
        /// <typeparam name="TKey">缓冲对象的键的类型。</typeparam>
        /// <typeparam name="TValue">缓冲对象的类型。</typeparam>
        /// <param name="key">缓冲池的键。</param>
        /// <param name="innerException">发生的内部异常。</param>
        private static ICache <TKey, TValue> RaiseCacheResolve <TKey, TValue>(string key,
                                                                              ConfigurationErrorsException innerException)
        {
            Contract.Requires(key != null);
            var events = CacheResolve;

            if (events != null)
            {
                var args = new CacheResolveEventArgs(
                    key, typeof(TKey), typeof(TValue), innerException);
                events(null, args);
                return(args.CacheObject as ICache <TKey, TValue>);
            }
            return(null);
        }