private IDeploymentTask BuildInstance(IInstanceBuilder builder, CommandSentence sentence) { try { var type = typeUniverse.Single(x => x.Name == sentence.Command.Name); var parameters = sentence.Command.Arguments.Select(x => x.Value); return((IDeploymentTask)builder.Create(type, parameters.ToArray())); } catch (InvalidOperationException) { throw new ScriptException($"Task '{sentence.Command.Name}' not found"); } }
private async Task <CommandSentence> TransformSentence(CommandSentence sentence) { var transformed = sentence.Command.Arguments.ToObservable().Select(x => Observable.FromAsync(async() => { var val = x.Value; if (val is string str) { return(new Argument(await pathBuilder.Replace(str))); } return(new Argument(val)); })) .Merge(1); var positionalArguments = await transformed.ToList(); return(new CommandSentence(new Command(sentence.Command.Name, positionalArguments))); }