bfr/BFR/Operations/Overwrite.cs
adroslice 704b7ea1a9 Added internal Operation Infrastructure + Example
- Overwrite might be a bad example, because it has no fail conditions. The intended behaviour for those is to throw an exception for invalid parameters, with an error text describing to the user what went wrong.
- Fail condition check may be moved to a seperate abstract method, forcing implementers to at least give fail conditions a thought.
- Minor refactor
- TODO: Better folder structure to group operations (Looking for suggestions)
2019-11-16 02:00:17 +01:00

28 lines
921 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(List<FileModel> files)
{
// Fail conditions: No fail conditions
// Apply Operation
foreach (var file in files)
if (FullName) file.FullName = Replacement;
else file.Name = Replacement;
}
}
}