示例#1
0
文件: Program.cs 项目: rmc00/gsf
        static void Main()
        {
            Arguments args;
            string arg;

            if (Environment.GetCommandLineArgs().Length > 1)
            {
                args = new Arguments(Environment.CommandLine, true);

                if (TryGetValue(args, "reportType", out arg) && !string.IsNullOrWhiteSpace(arg))
                {
                    arg = arg.Trim();

                    if (arg.Equals("completeness", StringComparison.OrdinalIgnoreCase))
                        GenerateCompletenessReport();
                    else if (arg.Equals("correctness", StringComparison.OrdinalIgnoreCase))
                        GenerateCorrectnessReport();
                }
                else
                {
                    // Generate completeness report by default
                    GenerateCompletenessReport();
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Main());
            }
        }
 protected virtual void OnBarCodeRecognized(Arguments e)
 {
     if (BarCodeRecognizedEvent != null)
     {
         BarCodeRecognizedEvent(this, e);
     }
 }
 private string GetUsage(Options options, Arguments arguments)
 {
     var usage = new StringBuilder();
     foreach (Option option in options)
     {
         if (usage.Length > 0)
             usage.Append(" ");
         if (option.Usage.MinOccurences == 0)
             usage.Append("[");
         usage.Append($"-{option.Name}");
         if (option.Usage.MaxParameters > 0)
             usage.Append(":(params)");
         if (option.Usage.MinOccurences == 0)
             usage.Append("]");
     }
     foreach (Argument argument in arguments)
     {
         if (usage.Length > 0)
             usage.Append(" ");
         if (argument.IsOptional)
             usage.Append("[");
         usage.Append($"<{argument["Name"] ?? "Arg"}>");
         if (argument.IsOptional)
             usage.Append("]");
     }
     return usage.ToString();
 }
示例#4
0
        static void Main(string[] args)
        {
            var arguments = new Arguments(args);
              if(arguments.InvalidArgs().Any()) {
            foreach(var arg in arguments.InvalidArgs()) {
              Console.WriteLine("--{0} : {1}", arg.Item1, arg.Item2);
            }
            return;
              }

              String versionText = File.ReadAllText(arguments.File).Trim();
              var version = RedmondVersion.Parse(versionText);

              switch(arguments.Increment) {
            case "major":
              version.IncrementMajor();
              break;
            case "minor":
              version.IncrementMinor();
              break;
            case "build":
              version.IncrementBuild();
              break;
            case "revision":
            default:
              version.IncrementRevision();
              break;
              }

              File.WriteAllText(arguments.File, version.ToString());
        }
示例#5
0
        public static int Main(string[] args)
        {
            //setup log4net
            log4net.Config.XmlConfigurator.Configure();

            int returnValue = -1;

            if (args.Length != 0)
            {
                //create the arguments
                Arguments arguments = new Arguments(args);

                //setup a task and run it
                MigrationTask task = Factory.Get<IMigrationTaskFactory>().GetMigrationTaskByTaskType(arguments);

                returnValue = task.RunTask();
            }
            else
            {
                //no args were passed in, lets display the help contents
                string helpFile = Resources.HelpInstructions;
                Console.Write(helpFile);
            }
            return returnValue;
        }
示例#6
0
 private GithubRelease(Arguments arguments)
 {
     Version = arguments.Version;
     Download = arguments.Download;
     Size = arguments.Size;
     Author = arguments.Author;
 }
示例#7
0
        protected override void PostProcess()
        {
            //Do the TAB2DB import (tab delimited files)
            Arguments a = new Arguments(this.Arguments);
            String dbFileName = a["db"].Trim().ToLower();
            String fileName = a["tab"].Trim();
            String tableName = a["table"] == null ? "" : a["table"].Trim().ToLower();
            bool hasHeader = a["noheader"] == null ? true : false;

            //new 04/07/11 - append data without recreating the table
            //allows import of data where split across multiple files
            bool append = a["append"] == null ? false : true;

            //char delimiter = a["delimiter"] == null ? ',' : a["delimiter"].PadRight(1,',').ToCharArray(0,1)[0];
            this.Out.WriteLine("Importing file '{0}' to db '{1}'", System.IO.Path.GetFileName(fileName), dbFileName);
            try
            {
                int rowCount = STELLAR.Data.API.Delimited2DB(dbFileName, fileName, tableName, '\t', hasHeader, append);
                this.Out.WriteLine("{0} rows imported", rowCount);
            }
            catch (Exception ex)
            {
                this.Error.WriteLine(ex.Message);
            }
        }
/// <summary>
/// <para>Test if the first value is less than other.</para>
/// </summary>
/// <example><para>Example: Is 2 less than 2?</para>
/// <code>r.expr(2).lt(2).run(conn, callback)
/// </code></example>
                        public Lt lt ( Object exprA, params object[] exprs )
                        {
                        Arguments arguments = new Arguments(this);
                                arguments.CoerceAndAdd(exprA);
                                arguments.CoerceAndAddAll(exprs);
                        return new Lt (arguments );
                        }
示例#9
0
        public static string Invoke()
        {
            var subcommands = getSubcommands();

            // Retrieve the sub-command from the command line input.
            var arg = EnvUtils.GetArg(0);
            
            // Check for case of no input.
            if (arg == null)
            {
                return getSubcommandError(subcommands, SUB_CMD_REQ);
            }

            // Retrieve the sub-command method to execute.
            var method = findSubcommand(subcommands, arg);

            // Check for case of no sub-command found.
            if (method == null)
            {
                var msg = string.Format(SUB_CMD_INVALID_FMT, arg);
                return getSubcommandError(subcommands, msg);
            }

            // Invoke the sub-command.
            var subcommandArgs = new Arguments(EnvUtils.GetArgs(1));
            method.Invoke(null, new object[] { subcommandArgs });
            return null;
        }
示例#10
0
        static int Main(String[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            Arguments arguments = new Arguments();
            arguments.Parse(args);

            Runner runner = new Runner();

            var prevCtx = SynchronizationContext.Current;
            try
            {
                var syncCtx = new SingleThreadSynchronizationContext();
                SynchronizationContext.SetSynchronizationContext(syncCtx);

                var t = runner.RunAsync(arguments);
                t.ContinueWith(
                    delegate { syncCtx.Complete(); }, TaskScheduler.Default);

                syncCtx.RunOnCurrentThread();

                var results = t.GetAwaiter().GetResult();
                return results;
            }
            finally { SynchronizationContext.SetSynchronizationContext(prevCtx); }
        }
示例#11
0
 protected override bool ValidateArguments()
 {
     Arguments a = new Arguments(this.Arguments);
     if (a["rdf"] == null)
         return false;
     return true;
 }
        /// <summary>
        /// This implementation will not be implementing remote tokens, but will define the interface
        /// to be extended by ScriptCoreLib.Ultra.
        /// </summary>
        public CachedFileGeneratorBase(Arguments Arguments)
        {
            this.SourceVersionDir = Arguments.TargetDirectory.CreateSubdirectory("version");
            this.ConstructorArguments = Arguments;
            this.SourceVersion = new FileInfo(SourceVersionDir.FullName + "/" + Arguments.AssamblyFile.Name + "." + Arguments.Language.ToString() + ".version.txt");

        }
示例#13
0
 public override JSObject Invoke(JSObject thisBind, Arguments args)
 {
     var res = del(thisBind, args);
     if (res == null)
         return JSObject.Null;
     return res;
 }
        protected void RunWithArgumentsUnchecked(params string[] arguments)
        {
            var args = new Arguments(arguments);
            var runner = new ShovelRunner(ShovelStaticContext.TaskManager, args);

            runner.Execute();
        }
 public Arguments GetArgument()
 {
     var result = new Arguments();
     if (TransportMode.HasValue)
     {
         result.Add("TransportMode", TransportMode.Value.ToTrafficDeviationInformationString());
     }
     if (!string.IsNullOrEmpty(LineNumber))
     {
         result.Add("LineNumber", LineNumber);
     }
     if (SiteId.HasValue)
     {
         result.Add("SiteId",SiteId.Value.ToString());
     }
     if (FromDate.HasValue && ToDate.HasValue)
     {
         result.Add("FromDate", FromDate.Value.ToString("yyyy-MM-dd"));
         result.Add("ToDate", ToDate.Value.ToString("yyyy-MM-dd"));
     }
     if (FromDate.HasValue ^ ToDate.HasValue)
     {
         throw new ArgumentException("if any of the parameters FromDate or ToDate is set then both must be set");
     }
     return result;
 }
示例#16
0
        /// <summary>
        /// 
        /// </summary>
        public void RaiseEvent()
        {
            //TODO mettere l'ID del giocatore entrato
            Arguments wvParameters = new Arguments();

            OnRestore(wvParameters);
        }
        static int Main(string[] arguments)
        {
            Arguments splitArguments=null;
            try
            {
                 splitArguments = new Arguments(arguments);
                ExceptionFunctions.ForceVerbose = splitArguments.Exists(Arguments.DefaultArgumentPrefix + "verbose");
                string operation = splitArguments.String(Arguments.OperationArgument, true);

                AdapterFunctions.RunOperation(operation, splitArguments);
                return 0;
            } catch (Exception error)
            {
                string message = string.Empty
                    + Arguments.ErrorArgument + " " + ExceptionFunctions.Write(error, !ExceptionFunctions.ForceVerbose) + Environment.NewLine
                    + "Arguments: " + string.Join(" ", arguments) + Environment.NewLine;
                //if (ExceptionFunctions.ForceVerbose)
                //{
                //    message += ProcessFunctions.WriteProcessHeritage() + Environment.NewLine;
                //    message += ProcessFunctions.WriteSystemVariables() + Environment.NewLine;
                //}
                Console.Write(message);
                if (ExceptionFunctions.ForceVerbose)
                {
                    SwishFunctions.MessageTextBox(message, false);
                }
                return -1;
            }
        }
示例#18
0
        public static void RunJob(Arguments args)
        {
            const string ERROR_FORMAT
                = "{0} Expected: Client {1} <interval> <filename>";

            // Get optional interval parameter.
            var secInterval = args.PopArg<int>();
            if (secInterval == null)
            {
                ConsoleProc.TerminatingError(string.Format(
                    ERROR_FORMAT,
                    "Missing <interval> parameter.",
                    nameof(RunJob)));
            }

            // Get required filename parameter.
            var filename = string.Join(" ", args.PopRemainingArgs());
            if (string.IsNullOrWhiteSpace(filename))
            {
                ConsoleProc.TerminatingError(string.Format(
                    ERROR_FORMAT,
                    "Missing <filename> parameter.",
                    nameof(RunJob)));
            }

            // Execute command on server.
            RunCommand(() => CreateClient().RunJob(
                Directory.GetCurrentDirectory(), secInterval.Value, filename));
        }
示例#19
0
 protected virtual void OnRestore(Arguments e)
 {
     if (RestoreEvent != null)
     {
         RestoreEvent(this, e);
     }
 }
示例#20
0
 public Progress(Arguments.Progress argument)
 {
     InitializeComponent();
     InitializeView(argument.CallingForm);
     InitializeProcessor(argument.InputFilenames, argument.OutputDirectory);
     InitializePriority();
 }
示例#21
0
 string GetCacheKeyForArgs(Arguments arguments) {
   var sb = new StringBuilder();
   sb.Append(method_name_);
   foreach (var argument in arguments) {
     sb.Append(argument == null ? "::" : argument.ToString());
   }
   return sb.ToString();
 }
示例#22
0
        public void InlineSqlReadIntoStream()
        {
            var a = new Arguments("/i:foo bar");

            TextReader reader = new StreamReader(a.Inputs[0].Stream);
            string contents = reader.ReadToEnd();

            contents.Should().Be("foo bar");
        }
示例#23
0
文件: Program.cs 项目: avs009/gsf
        private static void GenerateCompletenessReport()
        {
            CompletenessReportGenerator completenessReportGenerator = new CompletenessReportGenerator();
            Arguments args = new Arguments(Environment.CommandLine, true);
            string arg;

            string reportLocation = "";
            string reportFileName = "";
            DateTime reportDate = DateTime.Now;
            double threshold;

            if (TryGetValue(args, "archiveLocation", out arg))
                completenessReportGenerator.ArchiveLocation = arg;

            if (TryGetValue(args, "reportLocation", out arg))
                reportLocation = arg;

            if (TryGetValue(args, "reportFileName", out arg))
                reportFileName = arg;

            if (TryGetValue(args, "title", out arg))
                completenessReportGenerator.TitleText = arg;

            if (TryGetValue(args, "company", out arg))
                completenessReportGenerator.CompanyText = arg;

            if (TryGetValue(args, "reportDate", out arg) && DateTime.TryParse(arg, out reportDate))
                completenessReportGenerator.ReportDate = reportDate;

            if (TryGetValue(args, "level4Threshold", out arg) && double.TryParse(arg, out threshold))
                completenessReportGenerator.Level4Threshold = threshold;

            if (TryGetValue(args, "level3Threshold", out arg) && double.TryParse(arg, out threshold))
                completenessReportGenerator.Level3Threshold = threshold;

            if (TryGetValue(args, "level4Alias", out arg))
                completenessReportGenerator.Level4Alias = arg;

            if (TryGetValue(args, "level3Alias", out arg))
                completenessReportGenerator.Level3Alias = arg;

            if (string.IsNullOrEmpty(reportFileName))
                reportFileName = string.Format("{0} {1:yyyy-MM-dd}.pdf", completenessReportGenerator.TitleText, completenessReportGenerator.ReportDate);

            reportLocation = FilePath.GetAbsolutePath(reportLocation);

            if (!Directory.Exists(reportLocation))
                Directory.CreateDirectory(reportLocation);

            string reportFilePath = Path.Combine(reportLocation, reportFileName);

            // Generate PDF report
            completenessReportGenerator.GenerateReport().Save(reportFilePath);

            // E-mail PDF report if parameters were provided
            EmailReport(args, string.Format("{0} {1} for {2:MMMM dd, yyyy}", completenessReportGenerator.CompanyText, completenessReportGenerator.TitleText, reportDate), reportFilePath);
        }
 public Arguments GetArgument()
 {
     if (TimeWindow < 0 || TimeWindow > 60)
     {
         throw new ArgumentException("Time window must be more than 0 minutes and max 60 minutes");
     }
     var result = new Arguments {{"SiteId", SiteId.ToString()}, {"TimeWindow", TimeWindow.ToString()}};
     return result;
 }
示例#25
0
        public ServiceRequest(
		string className,
		string serviceName,
		Arguments arguments)
        {
            this.Class = className;
            this.Name = serviceName;
            this.Arguments = (arguments == null ? new Arguments() : arguments);
        }
示例#26
0
 public string Execute(Arguments arg, Stream stream)
 {
     var repository = new RepositoryXML(stream);
     var activities = repository.List();
     foreach(var activity in activities)
     {
         repository.Delete(activity.List()["id"]);
     }
     return "Clear all activities";
 }
示例#27
0
 private object ParseParameter(Arguments arguments, ITaskParameter p)
 {
     try {
         return arguments.Parameter(p);
     } catch(RequiredParameterNotGivenException e) {
         throw new TaskRequiredParameterException(p, this);
     } catch (TypeParserNotFoundException e) {
         throw new TaskParameterException(p, this);
     }
 }
示例#28
0
 public void Invoke(Arguments arguments)
 {
     try {
         var taskObject = Resolver.Resolve(Method.DeclaringType);
         var methodArguments = MethodArgumentsFromCommandLineParameters(arguments);
         Method.Invoke(taskObject, methodArguments);
     } catch (TargetInvocationException e) {
         throw new TaskException(this, e.InnerException);
     }
 }
		protected virtual IDictionary GetArguments(MethodInfo method, object[] arguments)
		{
			var argumentMap = new Arguments();
			var parameters = method.GetParameters();
			for (int i = 0; i < parameters.Length; i++)
			{
				argumentMap.Add(parameters[i].Name, arguments[i]);
			}
			return argumentMap;
		}
示例#30
0
        public void StartGame(Arguments args)
        {
            Launch = new LaunchArguments(args);
            Ui.ResetAll();
            Game.Settings.Save();

            if (Launch.Benchmark)
            {
                Log.AddChannel("cpu", "cpu.csv");
                Log.Write("cpu", "tick;time [ms]");

                Log.AddChannel("render", "render.csv");
                Log.Write("render", "frame;time [ms]");

                Console.WriteLine("Saving benchmark data into {0}".F(Path.Combine(Platform.SupportDir, "Logs")));

                Game.BenchmarkMode = true;
            }

            // Join a server directly
            var connect = Launch.GetConnectAddress();
            if (!string.IsNullOrEmpty(connect))
            {
                var parts = connect.Split(':');

                if (parts.Length == 2)
                {
                    var host = parts[0];
                    var port = Exts.ParseIntegerInvariant(parts[1]);
                    Game.LoadShellMap();
                    Game.RemoteDirectConnect(host, port);
                    return;
                }
            }

            // Load a replay directly
            if (!string.IsNullOrEmpty(Launch.Replay))
            {
                var replayMeta = ReplayMetadata.Read(Launch.Replay);
                if (ReplayUtils.PromptConfirmReplayCompatibility(replayMeta, Game.LoadShellMap))
                    Game.JoinReplay(Launch.Replay);

                if (replayMeta != null)
                {
                    var mod = replayMeta.GameInfo.Mod;
                    if (mod != null && mod != Game.ModData.Manifest.Mod.Id && ModMetadata.AllMods.ContainsKey(mod))
                        Game.InitializeMod(mod, args);
                }

                return;
            }

            Game.LoadShellMap();
            Game.Settings.Save();
        }