/// <summary> /// 取得所有自动刷新路片路径列表. /// </summary> /// <returns>自动刷新路片路径列表.</returns> /// <param name="iType">类型.</param> public List <string> GetRefreshImagePathsByType(ImagesRefreshType iType) { List <string> _tmps = null; List <string> _paths = null; foreach (AutoRefreshImagesInfo loop in this.Data.Settings) { if (iType != loop.Type) { continue; } _tmps = loop.Paths; break; } if ((null == _tmps) || (0 >= _tmps.Count)) { return(null); } _paths = new List <string> (); foreach (string path in _tmps) { string _path = string.Format("{0}{1}/{2}", this.Data.Root, iType.ToString(), path); _paths.Add(_path); } return(_paths); }
/// <summary> /// 刷新. /// </summary> /// <param name="iType">类型.</param> public void Refresh(ImagesRefreshType iType) { AutoRefreshImagesInfo objRet = null; foreach (AutoRefreshImagesInfo loop in Settings) { if (iType != loop.Type) { continue; } objRet = loop; break; } if (null == objRet) { objRet = AutoRefreshImagesInfo.Create(this.Root, iType); if (null != objRet) { this.Settings.Add(objRet); } } else { objRet.Refresh(this.Root); } }
/// <summary> /// 创建. /// </summary> /// <param name="iRootDir">根目录.</param> /// <param name="iType">类型.</param> public static AutoRefreshImagesInfo Create( string iRootDir, ImagesRefreshType iType) { AutoRefreshImagesInfo objRet = new AutoRefreshImagesInfo(); if ((null != objRet) && (false != objRet.Init(iRootDir, iType))) { return(objRet); } return(null); }
/// <summary> /// 初始化. /// </summary> /// <param name="iRootDir">根目录.</param> /// <param name="iType">类型.</param> public bool Init(string iRootDir, ImagesRefreshType iType) { this.Init(); if (true == string.IsNullOrEmpty(iRootDir)) { return(false); } if ((ImagesRefreshType.None >= iType) || (iType >= ImagesRefreshType.Max)) { return(false); } this.Type = iType; string _rootDir = string.Format("{0}{1}", iRootDir, iType.ToString()); List <FileInfo> files = GetAllFilesFromDir(_rootDir); if ((null == files) || (0 >= files.Count)) { return(false); } List <string> _files = this.CheckFiles(files); if ((null != _files) && (0 < _files.Count)) { foreach (string newFile in _files) { bool isExist = false; foreach (string oldFile in this.Paths) { if (false == oldFile.Equals(newFile)) { continue; } isExist = true; break; } if (false == isExist) { this.Paths.Add(newFile); } } } return(true); }
/// <summary> /// 清空. /// </summary> public override void Clear() { base.Clear(); Type = ImagesRefreshType.None; Paths.Clear(); }
/// <summary> /// 初始化. /// </summary> public override void Init() { base.Init(); Type = ImagesRefreshType.None; }