public void AddCommand(IGeneratorCommand command) { if (Stack.Count > 0) { Stack.Peek().Commands.Add(command); } }
public List <IGeneratorCommand> Convert(IEnumerable <RawCommand> commands) { bool allCommandsFound = true; List <IGeneratorCommand> foundCommands = new(); foreach (RawCommand rawCommand in commands) { IGeneratorCommand command = this.FindCommand(rawCommand.Name); if (command == null) { allCommandsFound = false; GeneratorErrors.CommandNotFoundError(rawCommand); } else { command.Parse(rawCommand.Parameters); foundCommands.Add(command); } } if (!allCommandsFound) { GeneratorErrors.CommandDocumentationHint(); } return(foundCommands); }
public void Measure(Measurement measurement, IGeneratorCommand command) { measurement.Stop(); this.Data.RanCommands.Add(new CommandStatistic { Command = command.Names.First(), Duration = measurement.Elapsed }); }
public IGeneratorCommandResult Run(IGeneratorCommand command) { if (!string.IsNullOrEmpty(command.Parameters.Output)) { this.output.Move(command.Parameters.Output); } if (!command.Parameters.SkipAsyncCheck) { if (!command.Parameters.IsOnlyAsync && command.Parameters.IsAsync) { return(new SwitchAsyncResult()); } bool?isAssemblyAsync = command.Parameters.IsAsyncAssembly; if (!command.Parameters.IsAsync) { if (!string.IsNullOrEmpty(command.Parameters.Assembly)) { LocateAssemblyResult locateAssemblyResult = GeneratorAssemblyLocator.Locate(command.Parameters.Assembly, command.Parameters.IsBeforeBuild); if (locateAssemblyResult.SwitchContext) { return(locateAssemblyResult); } isAssemblyAsync = locateAssemblyResult.Assembly?.IsAsync(); } } if (isAssemblyAsync != null) { if (!command.Parameters.IsOnlyAsync && isAssemblyAsync.Value) { return(new SwitchAsyncResult()); } if (command.Parameters.IsOnlyAsync && !command.Parameters.IsAsync && !isAssemblyAsync.Value) { return(new SwitchAsyncResult()); } } } Measurement measurement = this.statisticsService.StartMeasurement(); try { return(command.Run()); } finally { this.statisticsService.Measure(measurement, command); } }
public static string toCanonicalCommandName(this IGeneratorCommand command) { return(command.GetType().toCannonicalCommandName()); }
public Generator RegisterCommand(IGeneratorCommand generator) { this.resolver.Bind <IGeneratorCommand>().To(generator); return(this); }