using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using Gallium;
namespace Nitride.Handlebars;
///
/// An operation that discovers which text files have a Handlebars template
/// based on a component.
///
[WithProperties]
public partial class IdentifyHandlebarsFromComponent : IOperation
{
private readonly IValidator validator;
public IdentifyHandlebarsFromComponent(IValidator validator)
{
this.validator = validator;
}
public Func HasHandlebarsTest { get; set; } = null!;
///
public IEnumerable Run(IEnumerable input)
{
this.validator.ValidateAndThrow(this);
return input.Select(
(entity) => this.HasHandlebarsTest.Invoke(entity) ? entity.Set(HasHandlebarsTemplate.Instance) : entity);
}
}