本文整理汇总了C#中System.ConsoleOptions类的典型用法代码示例。如果您正苦于以下问题:C# ConsoleOptions类的具体用法?C# ConsoleOptions怎么用?C# ConsoleOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConsoleOptions类属于System命名空间,在下文中一共展示了ConsoleOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public override bool Process (DataNode dataNode, ConsoleOptions options)
{
if (options.Values.Count == 0)
return false;
string jsonPath = options.Values[0];
using (FileStream stream = File.OpenWrite(jsonPath)) {
using (StreamWriter writer = new StreamWriter(stream)) {
if (dataNode is TagDataNode) {
TagDataNode tagNode = dataNode as TagDataNode;
WriteNbtTag(writer, tagNode.Tag);
}
else if (dataNode is NbtFileDataNode) {
dataNode.Expand();
TagNodeCompound root = new TagNodeCompound();
foreach (DataNode child in dataNode.Nodes) {
TagDataNode childTagNode = child as TagDataNode;
if (childTagNode == null)
continue;
if (childTagNode.Tag != null)
root.Add(childTagNode.NodeName, childTagNode.Tag);
}
WriteNbtTag(writer, root);
}
}
}
return true;
}
示例2: SetUp
public void SetUp()
{
assemblyOptions = new ConsoleOptions(new string[]
{ firstAssembly, secondAssembly });
fixtureOptions = new ConsoleOptions(new string[]
{ "-fixture:"+fixture, firstAssembly, secondAssembly });
}
示例3: Process
public override bool Process(DataNode dataNode, ConsoleOptions options)
{
string value = options.Values[0];
TagDataNode tagDataNode = dataNode as TagDataNode;
return tagDataNode.Parse(value);
}
示例4: CanRecognizeBooleanOptions
public void CanRecognizeBooleanOptions(string propertyName, string pattern)
{
Console.WriteLine("Testing " + propertyName);
string[] prototypes = pattern.Split('|');
PropertyInfo property = GetPropertyInfo(propertyName);
Assert.AreEqual(typeof(bool), property.PropertyType, "Property '{0}' is wrong type", propertyName);
foreach (string option in prototypes)
{
ConsoleOptions options = new ConsoleOptions("-" + option);
Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize -" + option);
options = new ConsoleOptions("-" + option + "+");
Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize -" + option + "+");
options = new ConsoleOptions("-" + option + "-");
Assert.AreEqual(false, (bool)property.GetValue(options, null), "Didn't recognize -" + option + "-");
options = new ConsoleOptions("--" + option);
Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize --" + option);
options = new ConsoleOptions("/" + option);
Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize /" + option);
}
}
示例5: FixtureNamePlusAssemblyIsValid
public void FixtureNamePlusAssemblyIsValid()
{
ConsoleOptions options = new ConsoleOptions( "-fixture:NUnit.Tests.AllTests", "nunit.tests.dll" );
Assert.AreEqual("nunit.tests.dll", options.Parameters[0]);
Assert.AreEqual("NUnit.Tests.AllTests", options.fixture);
Assert.IsTrue(options.Validate());
}
示例6: HelpTextUsesCorrectDelimiterForPlatform
public void HelpTextUsesCorrectDelimiterForPlatform()
{
string helpText = new ConsoleOptions().GetHelpText();
char delim = System.IO.Path.DirectorySeparatorChar == '/' ? '-' : '/';
string expected = string.Format( "{0}output=", delim );
StringAssert.Contains( expected, helpText );
expected = string.Format( "{0}out=", delim );
StringAssert.Contains( expected, helpText );
}
示例7: Process
public override bool Process (DataNode dataNode, ConsoleOptions options)
{
Console.WriteLine(TypePrinter.Print(dataNode, options.ShowTypes));
if (dataNode.IsContainerType) {
foreach (var child in dataNode.Nodes)
Console.WriteLine(" | " + TypePrinter.Print(child, options.ShowTypes));
}
return true;
}
示例8: PrintSubTree
private void PrintSubTree (DataNode dataNode, ConsoleOptions options, string indent, bool last)
{
Console.WriteLine(indent + " + " + TypePrinter.Print(dataNode, options.ShowTypes));
indent += last ? " " : " |";
int cnt = 0;
dataNode.Expand();
foreach (DataNode child in dataNode.Nodes) {
cnt++;
PrintSubTree(child, options, indent, cnt == dataNode.Nodes.Count);
}
}
示例9: ExcludeCategories
public void ExcludeCategories()
{
ConsoleOptions options = new ConsoleOptions( "tests.dll", "-exclude:Database;Slow" );
Assert.IsTrue( options.Validate() );
Assert.IsNotNull(options.exclude);
Assert.AreEqual(options.exclude, "Database;Slow");
Assert.IsTrue(options.HasExclude);
string[] categories = options.ExcludedCategories;
Assert.IsNotNull(categories);
Assert.AreEqual(2, categories.Length);
Assert.AreEqual("Database", categories[0]);
Assert.AreEqual("Slow", categories[1]);
}
示例10: TestBooleanOption
private void TestBooleanOption( string fieldName, string option )
{
FieldInfo field = typeof(ConsoleOptions).GetField( fieldName );
Assert.IsNotNull( field, "Field '{0}' not found", fieldName );
Assert.AreEqual( typeof(bool), field.FieldType, "Field '{0}' is wrong type", fieldName );
ConsoleOptions options = new ConsoleOptions( "-" + option );
Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize -" + option );
options = new ConsoleOptions( "--" + option );
Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize --" + option );
options = new ConsoleOptions( false, "/" + option );
Assert.AreEqual( false, (bool)field.GetValue( options ), "Incorrectly recognized /" + option );
options = new ConsoleOptions( true, "/" + option );
Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize /" + option );
}
示例11: TestStringOption
private void TestStringOption( string fieldName, string option )
{
FieldInfo field = typeof(ConsoleOptions).GetField( fieldName );
Assert.IsNotNull( field, "Field {0} not found", fieldName );
Assert.AreEqual( typeof(string), field.FieldType );
ConsoleOptions options = new ConsoleOptions( "-" + option + ":text" );
Assert.AreEqual( "text", (string)field.GetValue( options ), "Didn't recognize -" + option );
options = new ConsoleOptions( "--" + option + ":text" );
Assert.AreEqual( "text", (string)field.GetValue( options ), "Didn't recognize --" + option );
options = new ConsoleOptions( false, "/" + option + ":text" );
Assert.AreEqual( null, (string)field.GetValue( options ), "Incorrectly recognized /" + option );
options = new ConsoleOptions( true, "/" + option + ":text" );
Assert.AreEqual( "text", (string)field.GetValue( options ), "Didn't recognize /" + option );
}
示例12: Process
public override bool Process (DataNode dataNode, ConsoleOptions options)
{
TagListDataNode listNode = dataNode as TagListDataNode;
listNode.Clear();
foreach (string value in options.Values) {
TagNode tag = TagDataNode.DefaultTag(listNode.Tag.ValueType);
TagDataNode tagData = TagDataNode.CreateFromTag(tag);
if (!tagData.Parse(value))
return false;
if (!listNode.AppendTag(tagData.Tag))
return false;
}
return true;
}
示例13: Run
public void Run()
{
this.options = ConsoleOptions.ParseArgs(this.args);
this.configuration = Configuration.LoadConfig(this.options.ConfigFile);
if (this.configuration != null)
{
Logger.SetupLogger(this.configuration.Get[Configuration.LogConfigFilePath]);
TestRunner.RunTests(this.configuration);
}
else
{
Console.WriteLine("Error. File config.xml not found or corrupted.");
}
if (this.options.Silent) return;
Console.Write("Press any key to exit.");
Console.ReadKey();
}
示例14: ServoSorter
public ServoSorter(
ICaptureGrab capture
,ConsoleOptions options) : base(capture)
{
_servoPosition = 70;
Settings = options.ColourSettings;
_debounceWatch = new Stopwatch();
var deviceFactory = new Pca9685DeviceFactory();
var device = deviceFactory.GetDevice(options.UseFakeDevice);
SetLogLevel(device);
_pwmControl = new ServoSortPwmControl(device);
_pwmControl.Init();
_detector = new ColourDetector();
}
示例15: OptionsValid
public override bool OptionsValid(ConsoleOptions options)
{
if (options.Values.Count == 0)
return false;
return true;
}