using System.Reflection;
namespace Elsa.Workflows.Management;
///
/// Provides an extensibility hook to resolve values for host method parameters.
/// Implementations can decide to resolve from workflow inputs, DI, context, or any other source.
///
public interface IHostMethodParameterValueProvider
{
///
/// Attempts to provide a value for the specified parameter.
/// Return a handled result when a value was provided (including null), otherwise return
/// to let other providers handle it.
///
ValueTask GetValueAsync(HostMethodParameterValueProviderContext context);
}
///
/// Result returned by .
///
public readonly record struct HostMethodParameterValueProviderResult(bool Handled, object? Value)
{
public static HostMethodParameterValueProviderResult Unhandled { get; } = new(false, null);
public static HostMethodParameterValueProviderResult HandledValue(object? value) => new(true, value);
}
///
/// Context passed to .
///
public record HostMethodParameterValueProviderContext(
IServiceProvider ServiceProvider,
ActivityExecutionContext ActivityExecutionContext,
IReadOnlyCollection InputDescriptors,
IActivity Activity,
ParameterInfo Parameter,
CancellationToken CancellationToken)
{
public string ParameterName => Parameter.Name ?? string.Empty;
}