예제 #1
0
        /// <summary>
        /// 定制最大长度为maxLength的LruDictionary。
        /// </summary>
        /// <param name="maxLruLength">需要设置的LruDictionary的最大长度。</param>
        /// <remarks>在默认情况下,LruDictionary的最大长度为100。此构造方法适用于构造指定最大长度的LruDictionary。
        /// <code source="..\Framework\TestProjects\DeluxeWorks.Library.Test\Core\LruDictionaryTest.cs" region="LruDictionaryTest" lang="cs" title="获取最大长度为maxLength的LruDictionary"/>
        /// <seealso cref="Framework.Core.EnumItemDescriptionAttribute"/>
        /// </remarks>
        public LruDictionary(int maxLruLength)
        {
            ExceptionHelper.TrueThrow <InvalidOperationException>(maxLruLength < 0, "maxLruLength must >= 0");

            this.maxLength = maxLruLength;
        }
예제 #2
0
        /// <summary>
        /// 判断LruDictionary中是否包含键值为Key值的元素
        /// </summary>
        /// <param name="key">键值Key</param>
        /// <returns>若LruDictionary中包含键值为key值的元素,则返回true,否则返回false</returns>
        /// <remarks>若返回值为true,由于该Key值的元素刚使用过,则把该元素放在LruDictionary的最前面。
        /// <code source="..\Framework\TestProjects\DeluxeWorks.Library.Test\Core\LruDictionaryTest.cs" region ="ContainsKeyTest" lang="cs" title="判断LruDictionary中是否包含键值为key的元素"/>
        /// <seealso cref="Framework.Core.EnumItemDescriptionAttribute"/>
        /// </remarks>
        public bool ContainsKey(TKey key)
        {
            ExceptionHelper.TrueThrow <ArgumentNullException>(key == null, "LruDictionary-ContainsKey-key");//add by yuanyong 20071227

            return(this.innerDictionary.ContainsKey(key));
        }