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