/// <summary> /// 初始化文件夹对象 /// </summary> /// <param name="pathInfo"></param> protected override void OnInitialize(IVxPathInfo pathInfo) { if (!pathInfo.Exists) { pathInfo.Create(VxPathType.Folder); } }
/// <summary> /// 校验一个虚拟路径对象是否一个文件对象 /// </summary> /// <param name="pathInfo"></param> /// <returns></returns> protected sealed override IVxPathInfo VerifyVxPathObject(IVxPathInfo pathInfo) { if (pathInfo.Exists && !pathInfo.IsFile) { throw new InvalidOperationException($"path {pathInfo.PhysicalPath} must be a file object."); } return(pathInfo); }
/// <summary> /// 构造函数 /// </summary> /// <param name="virtualPath"></param> protected VxIoObject(IVxPathInfo virtualPath) { if (virtualPath == null) { throw new ArgumentNullException(nameof(virtualPath)); } this.VxPathObject = this.VerifyVxPathObject(virtualPath); this.OnInitialize(this.VxPathObject); }
/// <summary> /// 构造函数 /// </summary> /// <param name="virtualPath"></param> public VxFileInfo(IVxPathInfo virtualPath) : base(virtualPath) { }
string IVxProviderInfo.GetFullPathString(IVxPathInfo pathInfo) => this.GetFullPathString(pathInfo as VxPathInfo);
IVxPathInfo IVxProviderInfo.GetParent(IVxPathInfo pathInfo) => this.GetParent(pathInfo as VxPathInfo);
IEnumerable <IVxPathInfo> IVxProviderInfo.GetFolders(IVxPathInfo pathInfo, string pattern) => this.GetFolders(pathInfo as VxPathInfo, pattern);
IEnumerable <IVxPathInfo> IVxProviderInfo.GetChildren(IVxPathInfo pathInfo, string pattern) => this.GetChildren(pathInfo as VxPathInfo, pattern);
/// <summary> /// 执行初始化 /// </summary> /// <param name="pathInfo"></param> protected virtual void OnInitialize(IVxPathInfo pathInfo) { }
/// <summary> /// 验证路径对象是否一个有效的目标对象 /// </summary> /// <param name="pathInfo"></param> /// <returns></returns> protected abstract IVxPathInfo VerifyVxPathObject(IVxPathInfo pathInfo);
/// <summary> /// 构造函数 /// </summary> /// <param name="virtualPath"></param> public VxFolderInfo(IVxPathInfo virtualPath) : base(virtualPath) { }