/// <summary>Create move op.</summary> public DeleteTree(IOperationSession session, IFileSystem filesystem, string path, IOption srcOption = null, IOption dstOption = null, OperationPolicy policy = OperationPolicy.Unset) : base(session, policy) { this.fileSystem = filesystem ?? throw new ArgumentNullException(nameof(filesystem)); this.path = path ?? throw new ArgumentNullException(nameof(path)); this.srcOption = srcOption; this.Option = dstOption; }
/// <summary> /// Create create directory op. /// </summary> /// <param name="session"></param> /// <param name="filesystem"></param> /// <param name="path"></param> /// <param name="option"></param> /// <param name="policy">(optional) Responds to <see cref="OperationPolicy.DstThrow"/>, <see cref="OperationPolicy.DstSkip"/> and <see cref="OperationPolicy.DstOverwrite"/> policies</param> public CreateDirectory(IOperationSession session, IFileSystem filesystem, string path, IOption option = null, OperationPolicy policy = OperationPolicy.Unset) : base(session, policy) { this.fileSystem = filesystem ?? throw new ArgumentNullException(nameof(filesystem)); this.path = path ?? throw new ArgumentNullException(nameof(path)); // Can rollback if can delete this.CanRollback = filesystem.CanDelete(); this.Option = option; }
/// <summary>Create batch op.</summary> public Batch(IOperationSession session, OperationPolicy policy, params IOperation[] ops) : base(session, policy) { if (ops != null) { this.Ops.AddRange(ops); } this.CanRollback = true; }
/// <summary>Create batch op.</summary> public Batch(IOperationSession session, OperationPolicy policy, IEnumerable <IOperation> ops) : base(session, policy) { if (ops != null) { this.Ops.AddRange(ops); } this.CanRollback = true; }
/// <summary>Create move op.</summary> public CopyTree(IOperationSession session, IFileSystem srcFilesystem, string srcPath, IFileSystem dstFilesystem, string dstPath, IOption srcOption = null, IOption dstOption = null, OperationPolicy policy = OperationPolicy.Unset) : base(session, policy) { this.srcFileSystem = srcFilesystem ?? throw new ArgumentNullException(nameof(srcFilesystem)); this.dstFileSystem = dstFilesystem ?? throw new ArgumentNullException(nameof(dstFilesystem)); this.srcPath = srcPath ?? throw new ArgumentNullException(nameof(srcPath)); this.dstPath = dstPath ?? throw new ArgumentNullException(nameof(dstPath)); this.srcOption = srcOption; this.Option = dstOption; }
/// <summary> /// Create delete directory op. /// </summary> /// <param name="session"></param> /// <param name="filesystem"></param> /// <param name="path"></param> /// <param name="recurse"></param> /// <param name="option">(optional) </param> /// <param name="policy">(optional) Responds to <see cref="OperationPolicy.DstThrow"/> and <see cref="OperationPolicy.DstSkip"/> policies.</param> /// <param name="rollback">(optional) Rollback operation</param> public Delete(IOperationSession session, IFileSystem filesystem, string path, bool recurse, IOption option = null, OperationPolicy policy = OperationPolicy.Unset, OperationBase rollback = null) : base(session, policy) { this.fileSystem = filesystem ?? throw new ArgumentNullException(nameof(filesystem)); this.path = path ?? throw new ArgumentNullException(nameof(path)); this.Recurse = recurse; this.rollback = rollback; this.CanRollback = rollback != null; this.Option = option; }
/// <summary>Create move op.</summary> public Move(IOperationSession session, IFileSystem srcFilesystem, string srcPath, IFileSystem dstFilesystem, string dstPath, IOption srcOption = null, IOption dstOption = null, OperationPolicy policy = OperationPolicy.Unset) : base(session, policy) { this.srcFileSystem = srcFilesystem ?? throw new ArgumentNullException(nameof(srcFilesystem)); this.dstFileSystem = dstFilesystem ?? throw new ArgumentNullException(nameof(dstFilesystem)); this.srcPath = srcPath ?? throw new ArgumentNullException(nameof(srcPath)); this.dstPath = dstPath ?? throw new ArgumentNullException(nameof(dstPath)); if (srcFileSystem != dstFileSystem) { throw new ArgumentException($"Move implementation requires that {nameof(srcFilesystem)} and {nameof(dstFilesystem)} are same. Use MoveTree instead."); } this.srcOption = srcOption; this.Option = dstOption; }
/// <summary>Set new policy</summary> public static IOperationSession SetCancellationSource(this IOperationSession session, CancellationTokenSource cancelSrc) { session.CancelSrc = cancelSrc; return(session); }
/// <summary>Set new policy</summary> public static IOperationSession SetProgressInterval(this IOperationSession session, long progressInterval) { session.ProgressInterval = progressInterval; return(session); }
/// <summary>Set new policy</summary> public static IOperationSession SetPolicy(this IOperationSession session, OperationPolicy newPolicy) { session.Policy = newPolicy; return(session); }
/// <summary> /// Create filesystem operation /// </summary> /// <param name="session">operation session</param> /// <param name="policy">operation specific policy</param> public OperationBase(IOperationSession session, OperationPolicy policy) { this.session = session ?? throw new ArgumentNullException(nameof(session)); this.OpPolicy = policy; }