using System.Collections.Generic; using FluentValidation; using MfGames.Gallium; using Zio; namespace MfGames.Nitride.IO.Paths; [WithProperties] public partial class AddPathPrefix : OperationBase { private readonly ReplacePath replacePath; private readonly IValidator validator; public AddPathPrefix( IValidator validator, ReplacePath replacePath) { this.validator = validator; this.replacePath = replacePath; } /// /// Gets or sets the prefix for the path operations. /// public UPath? PathPrefix { get; set; } public override IEnumerable Run(IEnumerable input) { this.validator.ValidateAndThrow(this); return this.replacePath.WithReplacement(this.RunReplacement) .Run(input); } private UPath RunReplacement( Entity _, UPath path) { string innerRelativePath = path.ToString() .TrimStart('/'); return this.PathPrefix!.Value / innerRelativePath; } }