⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 extendedformattime.cs

📁 HeyCacher 高性能缓存方案(带源码) 1. 文件的所有权益归上传用户所有 2. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途 3. CSDN下载频道仅提供交流平台
💻 CS
字号:
//===============================================================================
// CSDN HeyCache 
//===============================================================================
// 修改记录:[按最后修改时间倒排序]
// 2007.06.11 by tangwei
//
// 代码来源:参考于dotnet企业库3.0版
//===============================================================================
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Permissions;
using Microsoft.Practices.EnterpriseLibrary.Caching.Properties;

namespace HeyCacher.Components.Expirations
{
    /// <summary>
    ///	按特定时间为依赖的失效策略中的时间参数
    /// </summary>
    [Serializable]
    [ComVisible(false)]
    public class ExtendedFormatTime : ICacheItemExpiration
    {
        public string TimeFormat
        {
            get { return extendedFormat; }
        }
        private string extendedFormat;
        private DateTime lastUsedTime;

        public ExtendedFormatTime() { }
        public ExtendedFormatTime(string timeFormat)
        {
            innerCreate(timeFormat);
        }    

        public void Create(params string[] Params)
        {
            innerCreate(Params[0]);
        }
        private void innerCreate(string timeFormat)
        {
            // check arguments
            if (string.IsNullOrEmpty(timeFormat))
            {
                throw new ArgumentException(Resources.ExceptionNullTimeFormat, "timeFormat");
            }

            ExtendedFormat.Validate(timeFormat);

            // Get the modified extended format
            this.extendedFormat = timeFormat;

            // Convert to UTC in order to compensate for time zones		
            this.lastUsedTime = DateTime.Now.ToUniversalTime();
        }

        public bool HasExpired()
        {
            // Convert to UTC in order to compensate for time zones		
            DateTime nowDateTime = DateTime.Now.ToUniversalTime();

            ExtendedFormat format = new ExtendedFormat(extendedFormat);
            // Check expiration
            if (format.IsExpired(lastUsedTime, nowDateTime))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public void Notify()
        {
        }
        public void Initialize(ExpirationItem owningCacheItem)
        {
        } 
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -