本文整理汇总了C#中Option.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Option.Equals方法的具体用法?C# Option.Equals怎么用?C# Option.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option.Equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EqualsSameValue
public void EqualsSameValue([Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string option, [Values(OptionName.Controls, OptionName.Sound, OptionName.UnlockedLevel)] string comparer)
{
Option o = new Option() { Name = option, Value = OnOffOption.On };
Option c = new Option() { Name = comparer, Value = OnOffOption.On };
bool result = o.Equals(c);
bool expected = option.Equals(comparer);
Assert.AreEqual(expected, result);
}
示例2: ContainedObjectEquality
public void ContainedObjectEquality([Random(int.MinValue, int.MaxValue, 1)] int random)
{
var option = new Option<int>(random);
var value = random;
Assert.That(option.Equals(value));
Assert.That(option == value);
Assert.That(value == option);
Assert.That(option != value, Is.False);
Assert.That(value != option, Is.False);
}
示例3: ContainedObjectInequality
public void ContainedObjectInequality(
[Random(int.MinValue, int.MaxValue, 1)] int random0,
[Random(int.MinValue, int.MaxValue, 1)] int random1)
{
if (random0 == random1)
{
Assert.Inconclusive();
}
var option = new Option<int>(random0);
var value = random1;
Assert.That(option.Equals(value), Is.False);
Assert.That(option == value, Is.False);
Assert.That(value == option, Is.False);
Assert.That(option != value);
Assert.That(value != option);
}
示例4: processMatchedSwitch
protected int processMatchedSwitch(Option s, string[] cmdlineArgs, int pos)
{
//if help switch is matched give help .. only works for console apps
if (s.Equals(_help))
{
if (isConsoleApplication)
{
Console.Write(this.HelpMessage());
}
}
//process bool switch
if (s.Type == typeof(bool) && s.needsValue == false)
{
s.Value = true;
return pos;
}
if (s.needsValue == true)
{
//retrieve parameter value and adjust pos
string parameter = "";
pos = retrieveParameter(ref parameter, s.Name, cmdlineArgs, pos);
//parse option using 'IParsableOptionParameter.parseValue(parameter)'
//and set parameter value
try
{
if (s.Type != null)
{
((IParsableOptionParameter)s).Value = ((IParsableOptionParameter)s).parseValue(parameter);
return pos;
}
}
catch (Exception ex)
{
throw new ParameterConversionException(ex.Message);
}
}
//unsupported type ..
throw new CMDLineParserException("Unsupported Parameter Type:" + s.Type);
}
示例5: ContainedObjectBoxedEquality
public void ContainedObjectBoxedEquality([Random(int.MinValue, int.MaxValue, 1)] int random)
{
var option = new Option<int>(random);
var box = (object) random;
Assert.That(option.Equals(box));
}
示例6: NullReferenceNoneInequality
public void NullReferenceNoneInequality()
{
var option = new Option<string>();
string value = null;
Assert.That(option.Equals(value), Is.False);
Assert.That(option == value, Is.False);
Assert.That(value == option, Is.False);
Assert.That(option != value);
Assert.That(value != option);
}
示例7: NullReferenceInequality
public void NullReferenceInequality([Random(int.MinValue, int.MaxValue, 1)] int random)
{
var option = new Option<string>(random.ToString());
string value = null;
Assert.That(option.Equals(value), Is.False);
Assert.That(option == value, Is.False);
Assert.That(value == option, Is.False);
Assert.That(option != value);
Assert.That(value != option);
}
示例8: NoneInequality
public void NoneInequality([Random(int.MinValue, int.MaxValue, 1)] int random)
{
var option = new Option<int>();
var value = random;
Assert.That(option.Equals(value), Is.False);
Assert.That(option == value, Is.False);
Assert.That(value == option, Is.False);
Assert.That(option != value);
Assert.That(value != option);
}