Execute() public method

public Execute ( ) : void
return void
Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var arguments = new Dictionary<string, string>();

             // App.Config Settings
             var appSettingKeys = ConfigurationManager.AppSettings.Keys;
             for (var i = 0; i < appSettingKeys.Count; i++)
             {
            var key = appSettingKeys[i];
            arguments.AddOrUpdate(key, ConfigurationManager.AppSettings[key]);
             }

             // Manual override through CLI.
             var p = new OptionSet()
                    {
                       {
                          "<>", v =>
                                   {
                                      if (!v.StartsWith("--"))
                                         return;
                                      var split = v.Split(new[] { '=' }, 2);
                                      if (split.Length != 2)
                                         return;
                                      arguments.AddOrUpdate(split[0].TrimStart('-'), split[1]);
                                   }
                          }
                    };

             p.Parse(args);

             var loader = new AssemblyLoader();
             var dbProvider = loader.CreateTypeFromAssembly<DbProvider>(arguments["dbp.provider"], arguments);
             var dbCodeFormatter = loader.CreateTypeFromAssembly<DbTraceCodeFormatter>(arguments["tcf.provider"], arguments);
             var codeHighlighter = loader.CreateTypeFromAssembly<HighlightCodeProvider>(arguments["hcp.provider"], arguments);
             var outputProvider = loader.CreateTypeFromAssembly<OutputProvider>(arguments["out.provider"], arguments);

             switch (arguments["app.mode"].ToLower().Trim())
             {
            case "generate":
               var generateCommand = new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, arguments["app.traceName"]);
               generateCommand.Execute();
               break;

            case "start":
               var startCommand = new StartCommand(outputProvider, dbProvider, arguments["app.traceName"]);
               startCommand.Execute();
               break;

            case "stop":
               {
                  var stopCommand = new StopCommand(dbProvider, outputProvider, arguments["app.traceName"]);
                  stopCommand.Execute();
               }
               break;
             }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var arguments = ParseCommandLine(args);

             var loader = new AssemblyLoader();
             var dbProvider = loader.CreateTypeFromAssembly<DbProvider>(arguments["dbp.provider"], arguments);
             var dbCodeFormatter = loader.CreateTypeFromAssembly<DbTraceCodeFormatter>(arguments["tcf.provider"], arguments);
             var codeHighlighter = loader.CreateTypeFromAssembly<HighlightCodeProvider>(arguments["hcp.provider"], arguments);
             var outputProvider = loader.CreateTypeFromAssembly<OutputProvider>(arguments["out.provider"], arguments);

             var command = arguments["app.command"].ToLower().Trim();

             // Get trace name from provided, last trace, or generate one.
             var traceName = arguments["app.traceName"];
             if (traceName == null && command != "start")
             {
            traceName = dbProvider.GetLastTraceName();
             }
             else if (traceName == null && command == "start")
             {
            traceName = DateTime.Now.ToString("yyyyMMddHHmmss");
             }

             switch (command)
             {
            case "generate":
               var generateCommand = new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName);
               generateCommand.Execute();
               break;

            case "start":
               var startCommand = new StartCommand(outputProvider, dbProvider, traceName);
               startCommand.Execute();
               break;

            case "stop":
               var stopCommand = new StopCommand(dbProvider, outputProvider, traceName);
               stopCommand.Execute();
               break;

            case "finish":
               new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName).Execute();
               new StopCommand(dbProvider, outputProvider, traceName).Execute();

               break;
             }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var arguments = ParseCommandLine(args);
             RequiredAttributes(arguments,
             "databaseProvider",
             "codeFormatProvider",
             "codeHighlightProvider",
             "outputProvider",
             "action"
             );

             var loader = new AssemblyLoader();
             var dbProvider = loader.CreateTypeFromAssembly<DbProvider>(arguments["databaseProvider"], arguments);
             var dbCodeFormatter = loader.CreateTypeFromAssembly<DbTraceCodeFormatter>(arguments["codeFormatProvider"], arguments);
             var codeHighlighter = loader.CreateTypeFromAssembly<HighlightCodeProvider>(arguments["codeHighlightProvider"], arguments);
             var outputProvider = loader.CreateTypeFromAssembly<OutputProvider>(arguments["outputProvider"], arguments);

             var command = arguments["action"].ToLower().Trim();

              var traceName = arguments.ContainsKey("traceFileName") ? arguments["traceFileName"] : null;
             switch (command)
             {
            case "generate":

                 RequiredAttributes(arguments,
                 "traceFileName"
                );

               var generateCommand = new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName);
               generateCommand.Execute();
               break;

            case "execute":

                RequiredAttributes(arguments,
                 "target"
                );

               traceName = traceName ?? DateTime.Now.ToString("yyyyMMddHHmmss");
               var startCommand = new StartCommand(outputProvider, dbProvider, traceName);
               startCommand.Execute();

                 var executeCommand = new ExecuteCommand(arguments["target"], arguments.ContainsKey("targetArgs") ? arguments["targetArgs"] : string.Empty);
                 executeCommand.Execute();

                 var stopCommand = new StopCommand(dbProvider, outputProvider, traceName);
                 stopCommand.Execute();

               break;
             }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var arguments = ParseCommandLine(args);

            var loader = new AssemblyLoader();
            var dbProvider = loader.CreateTypeFromAssembly<DbProvider>(arguments["dbp.provider"], arguments);
            var dbCodeFormatter = loader.CreateTypeFromAssembly<DbTraceCodeFormatter>(arguments["tcf.provider"], arguments);
            var codeHighlighter = loader.CreateTypeFromAssembly<HighlightCodeProvider>(arguments["hcp.provider"], arguments);
            var outputProvider = loader.CreateTypeFromAssembly<OutputProvider>(arguments["out.provider"], arguments);

            var command = arguments["app.command"].ToLower().Trim();

            // Get trace name from provided, last trace, or generate one.
            string traceName = null;
            if (arguments.ContainsKey("app.traceName"))
            {
                traceName = arguments["app.traceName"];
            }
            if (traceName == null && command != "start")
            {
                traceName = dbProvider.GetLastTraceName();
            }
            else if (traceName == null && command == "start")
            {
                traceName = DateTime.Now.ToString("yyyyMMddHHmmss");
            }

            // Get the specific database object name to run against, if specified (mainly used for testing).
            if (arguments.ContainsKey("test.objectname"))
            {
                var objectName = arguments["test.objectname"];
                dbProvider.SetSpecificObjectNameForTesting(objectName);
            }

            switch (command)
            {
                case "generate":
                    var generateCommand = new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName);
                    generateCommand.Execute();
                    break;

                case "start":
                    var startCommand = new StartCommand(outputProvider, dbProvider, traceName);
                    startCommand.Execute();
                    break;

                case "stop":
                    var stopCommand = new StopCommand(dbProvider, outputProvider, traceName);
                    stopCommand.Execute();
                    break;

                case "finish":
                    new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName).Execute();
                    new StopCommand(dbProvider, outputProvider, traceName).Execute();
                    break;
            }
        }