public async Task RunScript( HellScript <HellScriptContext> script, Guid sessionId, CancellationToken cancellationToken = default) { logger.LogDebug($"Running script {script.Name}"); using var sdkUtilServiceProvider = MakeSdkUtilServiceProvider(); var context = new HellScriptContext( script.Name, scriptLogger, sessionManager.GetSession(sessionId), sdkUtilServiceProvider); await RunScript(script, context, cancellationToken); }
private async Task RunScript <THellScriptContext>( HellScript <THellScriptContext> script, THellScriptContext context, CancellationToken cancellationToken = default) where THellScriptContext : HellScriptContext { if (script.ContextType != typeof(THellScriptContext)) { throw new UnexpectedScriptTypeException(); } var state = await script.Script.RunAsync(context, e => true, cancellationToken); if (state.Exception != null) { throw new RuntimeScriptException(state.Exception); } }
public async Task <TOutput> RunScript <TInput, TOutput>( HellScript <HellScriptContext <TInput, TOutput> > script, Guid sessionId, TInput input, CancellationToken cancellationToken = default) where TInput : class where TOutput : class, new() { logger.LogDebug($"Running script {script.Name}"); using var sdkUtilServiceProvider = MakeSdkUtilServiceProvider(); var context = new HellScriptContext <TInput, TOutput>( script.Name, scriptLogger, sessionManager.GetSession(sessionId), sdkUtilServiceProvider, input); await RunScript(script, context, cancellationToken); return(context.Output); }