using Muchinfo.PC.Common.Helpers; using Muchinfo.MTPClient.Infrastructure.Enums; using System; using System.Data; namespace Muchinfo.MTPClient.Infrastructure.Cache { /// /// 缓存数据表类 /// public class CacheTable : DataTable { /// /// 缓存数据时间的键 /// private const string CacheTimeName = "CacheTime"; /// /// 缓存数据权限的键 /// private const string PremissionName = "Premission"; private CacheType _type; /// /// 获取或设置缓存表类型 /// public CacheType Type { get { return this._type; } } private DateTime _cacheTime; /// /// 获取或设置最后请求缓存数据的时间 /// public DateTime CacheTime { get { return this._cacheTime; } set { this._cacheTime = value; string cacheTime = value.ToString(FormatHelper.DateTimeFormat2); if (this.ExtendedProperties.Contains(CacheTable.CacheTimeName)) { ExtendedProperties[CacheTable.CacheTimeName] = cacheTime; } else { ExtendedProperties.Add(CacheTable.CacheTimeName, cacheTime); } } } private string m_Premission; /// /// 获取或设置请求缓存使用的权限 /// public string Premission { get { return m_Premission; } set { m_Premission = value; if (this.ExtendedProperties.Contains(CacheTable.PremissionName)) { ExtendedProperties[CacheTable.PremissionName] = value; } else { ExtendedProperties.Add(CacheTable.PremissionName, value); } } } /// /// Initializes a new instance of the class. /// /// 缓存数据类型 public CacheTable(CacheType type) { this._type = type; this.TableName = type.ToString(); } internal void InitExtentProperties() { this._type = (CacheType)Enum.Parse(typeof(CacheType), TableName); if (this.ExtendedProperties.Contains(CacheTable.CacheTimeName)) { DateTime.TryParse(string.Empty + ExtendedProperties[CacheTable.CacheTimeName], out _cacheTime); } if (this.ExtendedProperties.Contains(CacheTable.PremissionName)) { this.m_Premission = string.Empty + ExtendedProperties[CacheTable.PremissionName]; } } } }