本文整理汇总了C#中Record.HasField方法的典型用法代码示例。如果您正苦于以下问题:C# Record.HasField方法的具体用法?C# Record.HasField怎么用?C# Record.HasField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.HasField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetExpected
private static ResultInfo GetExpected(Record left, Record right, IEnumerable<IFieldComparer> comparerers)
{
foreach (var comparer in comparerers)
{
var fieldName = comparer.FieldName;
if (!left.HasField(fieldName) || !right.HasField(fieldName))
{
return new ResultInfo
{
ShouldThrowDueToInvalidHeader = true
};
}
var leftValue = left[fieldName];
var rightValue = right[fieldName];
var result = comparer.Compare(leftValue, rightValue);
if (result != 0)
{
return new ResultInfo
{
Value = result
};
}
}
return new ResultInfo();
}
示例2: Given_a_record_with_1_field_and_field__1__is_requested__should_return_false
public void Given_a_record_with_1_field_and_field__1__is_requested__should_return_false()
{
var record = new Record("x");
var result = record.HasField(1);
result.ShouldBeFalse();
}
示例3: Given_a_record_with_field__a__and_field__b__is_requested__should_return_false
public void Given_a_record_with_field__a__and_field__b__is_requested__should_return_false()
{
var record = new Record(new[] { "x" }, new Dictionary<string, int>
{
{ "a", 0 }
});
var result = record.HasField("b");
result.ShouldBeFalse();
}
示例4: Given_a_negative_field_number_is_requested__should_throw_ArgumentOutOfRangeException
public void Given_a_negative_field_number_is_requested__should_throw_ArgumentOutOfRangeException()
{
var record = new Record("x");
// ReSharper disable ReturnValueOfPureMethodIsNotUsed
record.HasField(-1);
// ReSharper restore ReturnValueOfPureMethodIsNotUsed
}