public static void Main(string[] args) { AddCodeGenerationServices(_serviceProvider); //Debugger.Launch(); var generatorsLocator = _serviceProvider.GetRequiredService <ICodeGeneratorLocator>(); var logger = _serviceProvider.GetRequiredService <ILogger>(); if (args == null || args.Length == 0 || IsHelpArgument(args[0])) { ShowCodeGeneratorList(generatorsLocator.CodeGenerators); return; } try { var codeGeneratorName = args[0]; logger.LogMessage("Finding the generator '" + codeGeneratorName + "'..."); var generatorDescriptor = generatorsLocator.GetCodeGenerator(codeGeneratorName); var actionInvoker = new ActionInvoker(generatorDescriptor.CodeGeneratorAction); logger.LogMessage("Running the generator '" + codeGeneratorName + "'..."); actionInvoker.Execute(args); } catch (Exception ex) { while (ex is TargetInvocationException) { ex = ex.InnerException; } logger.LogMessage(ex.Message, LogMessageLevel.Error); } }
public int Execute(string [] args) { if (args == null || args.Length == 0 || IsHelpArgument(args[0])) { ShowCodeGeneratorList(_locator.CodeGenerators); return(0); } try { var codeGeneratorName = args[0]; _logger.LogMessage("Finding the generator '" + codeGeneratorName + "'..."); var generatorDescriptor = _locator.GetCodeGenerator(codeGeneratorName); var actionInvoker = new ActionInvoker(generatorDescriptor.CodeGeneratorAction); _logger.LogMessage("Running the generator '" + codeGeneratorName + "'..."); actionInvoker.Execute(args); } catch (Exception ex) { while (ex is TargetInvocationException) { ex = ex.InnerException; } _logger.LogMessage(ex.Message, LogMessageLevel.Error); _logger.LogMessage(ex.StackTrace, LogMessageLevel.Error); } return(0); }
public static void Main(string[] args) { var _serviceProvider = new ServiceProvider(); AddCodeGenerationServices(_serviceProvider); //Debugger.Launch(); var generatorsLocator = _serviceProvider.GetRequiredService<ICodeGeneratorLocator>(); var logger = _serviceProvider.GetRequiredService<ILogger>(); if (args == null || args.Length == 0 || IsHelpArgument(args[0])) { ShowCodeGeneratorList(generatorsLocator.CodeGenerators); return; } try { var codeGeneratorName = args[0]; logger.LogMessage("Finding the generator '" + codeGeneratorName + "'..."); var generatorDescriptor = generatorsLocator.GetCodeGenerator(codeGeneratorName); var actionInvoker = new ActionInvoker(generatorDescriptor.CodeGeneratorAction); logger.LogMessage("Running the generator '" + codeGeneratorName + "'..."); actionInvoker.Execute(args); } catch (Exception ex) { while (ex is TargetInvocationException) { ex = ex.InnerException; } logger.LogMessage(ex.Message, LogMessageLevel.Error); } }