using System.Collections.Generic;
using FluentValidation;
using Gallium;
using Zio;
namespace Nitride.IO.Paths;
///
/// Changes the extension of the paths given.
///
[WithProperties]
public partial class ChangePathExtension : IOperation
{
private readonly ReplacePath replacePath;
private readonly IValidator validator;
public ChangePathExtension(
IValidator validator,
ReplacePath replacePath)
{
this.validator = validator;
this.replacePath = replacePath;
}
///
/// Gets or sets the prefix for the path operations.
///
public string? Extension { get; set; }
public IEnumerable Run(IEnumerable input)
{
this.validator.ValidateAndThrow(this);
return this.replacePath.WithReplacement(this.RunReplacement)
.Run(input);
}
private UPath RunReplacement(
Entity _,
UPath path)
{
return path.ChangeExtension(this.Extension!);
}
}