Trying to implement my first CommandsFeature and am getting the error “No service for type ‘DVApi.Interface.wOBACalculatorCommand’ has been registered”.
public class wOBACalculatorCommand(
ICacheClientAsync cacheClientAsync,
IServiceGatewayAsync gatewayAsync,
ILogger<wOBACalculatorCommand> log)
: AsyncCommandWithResult<wOBACoefficients, wOBACoefficients>
{
protected override async Task<wOBACoefficients> RunAsync(wOBACoefficients req, CancellationToken token)
{
log.LogInformation("Got to wOBA command");
return req;
}
}
I have registered the plugin like so
[assembly: HostingStartup(typeof(DVApi.ConfigureCommands))]
namespace DVApi;
public class ConfigureCommands : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices((ctx, services) =>
{
services.AddPlugin(new CommandsFeature());
});
}
and here is how I am trying to call it…
public class DashService(ICommandExecutor cmdExecutor) : DVService
{
public async Task<DashPitcherBattedBallResponse> GetAsync(DashPitcherBattedBall req)
{
var resp = new DashPitcherBattedBallResponse();
resp.PopulateWith(req);
var cmd = cmdExecutor.Command<wOBACalculatorCommand>();
await cmd.ExecuteAsync(new wOBACoefficients());
return resp;
}
}