本文整理汇总了C#中System.Arguments类的典型用法代码示例。如果您正苦于以下问题:C# Arguments类的具体用法?C# Arguments怎么用?C# Arguments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Arguments类属于System命名空间,在下文中一共展示了Arguments类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
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());
}
}
示例2: OnBarCodeRecognized
protected virtual void OnBarCodeRecognized(Arguments e)
{
if (BarCodeRecognizedEvent != null)
{
BarCodeRecognizedEvent(this, e);
}
}
示例3: GetUsage
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: Main
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: Main
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: GithubRelease
private GithubRelease(Arguments arguments)
{
Version = arguments.Version;
Download = arguments.Download;
Size = arguments.Size;
Author = arguments.Author;
}
示例7: PostProcess
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);
}
}
示例8: lt
/// <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: Invoke
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: Main
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: ValidateArguments
protected override bool ValidateArguments()
{
Arguments a = new Arguments(this.Arguments);
if (a["rdf"] == null)
return false;
return true;
}
示例12: CachedFileGeneratorBase
/// <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: Invoke
public override JSObject Invoke(JSObject thisBind, Arguments args)
{
var res = del(thisBind, args);
if (res == null)
return JSObject.Null;
return res;
}
示例14: RunWithArgumentsUnchecked
protected void RunWithArgumentsUnchecked(params string[] arguments)
{
var args = new Arguments(arguments);
var runner = new ShovelRunner(ShovelStaticContext.TaskManager, args);
runner.Execute();
}
示例15: GetArgument
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;
}