bfr/BFR/Operations/Overwrite.cs
adroslice 0eb940012d Implemented preview TODO, modified exception handling
- Better handles unexpected exceptions
- Expected exceptions should be OperationException
- Leaves files unchanged even if the exception occurs at *any* point of the operation
- TODO: Probably have to optimize this.
- Operations now operate on IList<T> instead of List<T> to maintain compatibility with AvaloniaList<T>
- Slightly better comments
2019-11-16 02:47:07 +01:00

28 lines
922 B
C#

using System.Collections.Generic;
using BFR.DataModels;
namespace BFR.Operations
{
public class Overwrite : Operation
{
// Operation Info
public override string Name => nameof(Overwrite);
public override string Description => "Overwrites all file names. To produce a valid result this has to be combined with numbering.";
public override OperationType OperationType { get; } = OperationType.Make<Overwrite>();
// Operation Parameters
public string Replacement { get; set; } = "";
public bool FullName { get; set; } = false;
protected override void ApplyToInternal(IList<FileModel> files)
{
// Fail conditions: No fail conditions
// Apply Operation
foreach (var file in files)
if (FullName) file.FullName = Replacement;
else file.Name = Replacement;
}
}
}