本文整理汇总了C#中Parser.AddArguments方法的典型用法代码示例。如果您正苦于以下问题:C# Parser.AddArguments方法的具体用法?C# Parser.AddArguments怎么用?C# Parser.AddArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser.AddArguments方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ErrorTest
public void ErrorTest()
{
Parser target = new Parser();
IParameterEntity[] args = new IParameterEntity[]{
new DefinitionParameter("char", "测试", (LongOrSplitPrefix)"char", (ShortPrefix)'c'),
new ValueParameter("better", "好的", true, (LongOrSplitPrefix)"bet",(ShortPrefix)'b'),
new EnumParameter<MyEnum>("em", MyEnum.B, (LongOrSplitPrefix)"enum", (ShortPrefix)'e')
};
target.AddArguments(args);
target.Parse(new string[] { });
}
示例2: DefaultValue_Test
public void DefaultValue_Test()
{
ValueParameter av = new ValueParameter("av", "tt", true);
ValueParameter bv = new ValueParameter("bv", "bv", "ttbv");
Parser arg = new Parser();
arg.AddArguments(av, bv)
;
arg.Parse(new string[] {
"mwwtools" ,"io" ,"synch" ,@"/a", @"tt"
});
Assert.IsTrue(av.Defined);
Assert.AreEqual("tt", av.Value);
Assert.IsTrue(bv.Defined);
Assert.AreEqual("ttbv", bv.Value);
}
示例3: InitArgument
protected override void InitArgument(Parser parser) {
parser.AddArguments(ArgSourceFile, ArgDictXFile);
}
示例4: Parse_Test
public void Parse_Test()
{
string Argument_Destination = "destination";
string Argument_Source = "source";
string Argument_Archive = "archive";
string Argument_Length = "length";
string Argument_LastWriteTime = "lastwritetime";
string Argument_CleanArchive = "cleanarchive";
Parser arg = new Parser();
arg.AddArguments(new ValueParameter(Argument_Destination, "目标路径", true, (ShortPrefix)'d', (LongOrSplitPrefix)"dest"),
new ValueParameter(Argument_Source, "被比对路径", true, (ShortPrefix)'s', (LongOrSplitPrefix)"source"),
new DefinitionParameter(Argument_Length, "按文件长度是否一致来进行同步", (LongPrefix)"len", (ShortPrefix)'l'),
new DefinitionParameter(Argument_LastWriteTime, "按最后修改时间是否一致来进行同步", (LongPrefix)"time", (ShortPrefix)'t'),
new DefinitionParameter(Argument_CleanArchive, "是否清除存档标识", (LongPrefix)"clean", (ShortPrefix)'c'),
new DefinitionParameter(Argument_Archive, "按是否存档来进行同步", (LongPrefix)"archive", (ShortPrefix)'a'))
;
arg.Parse(new string[] {
"mwwtools" ,"io" ,"synch" ,@"/s", @"c:\a" ,@"/dest:c:\b" ,"/length" ,"-t"
});
Assert.IsTrue(arg.GetEntity<ValueParameter>(Argument_Source).Defined);
Assert.IsFalse(arg.GetEntity<DefinitionParameter>(Argument_Archive).Defined);
Assert.IsTrue(arg.GetEntity<DefinitionParameter>(Argument_LastWriteTime).Defined);
}
示例5: Parse_Test1
public void Parse_Test1()
{
var args = new IParameterEntity[]{
new DefinitionParameter("char", "测试", (LongOrSplitPrefix)"char", (ShortPrefix)'c'),
new ValueParameter("better", "好的", true, (LongOrSplitPrefix)"bet",(ShortPrefix)'b'),
new EnumParameter<MyEnum>("em", MyEnum.B, (LongOrSplitPrefix)"enum", (ShortPrefix)'e')
};
Parser target = new Parser();
target.AddArguments(args);
string[] argStrings = new string[] { "-char", "cvalue", "/bet:bvalue", "--enum", "c" };
target.Parse(argStrings);
Assert.AreEqual(false, (target.GetEntity<DefinitionParameter>("char").Defined));
Assert.AreEqual("bvalue", (target.GetEntity<ValueParameter>("better").Value));
Assert.AreEqual(MyEnum.C, (target.GetEntity<EnumParameter<MyEnum>>("em").Value));
}
示例6: Set
public void Set(Parser parser, PropertyInfo property)
{
parser.AddArguments(CreateParameter(property));
}
示例7: InitArgument
protected override void InitArgument(Parser parser)
{
parser.AddArguments(ArgCharacter);
}