示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
        }