本文整理匯總了C#中System.Reflection.Where方法的典型用法代碼示例。如果您正苦於以下問題:C# Reflection.Where方法的具體用法?C# Reflection.Where怎麽用?C# Reflection.Where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Reflection
的用法示例。
在下文中一共展示了Reflection.Where方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Map_boolean_switch_creates_boolean_value
public void Map_boolean_switch_creates_boolean_value()
{
// Fixture setup
var tokenPartitions = new[]
{
new KeyValuePair<string, IEnumerable<string>>("x", new [] { "true" })
};
var specProps = new[]
{
SpecificationProperty.Create(
new OptionSpecification("x", string.Empty, false, string.Empty, Maybe.Nothing<int>(), Maybe.Nothing<int>(), '\0', Maybe.Nothing<object>(), string.Empty, string.Empty, new List<string>(), typeof(bool), TargetType.Switch),
typeof(Simple_Options).GetProperties().Single(p => p.Name.Equals("BoolValue", StringComparison.Ordinal)),
Maybe.Nothing<object>())
};
// Exercize system
var result = OptionMapper.MapValues(
specProps.Where(pt => pt.Specification.IsOption()),
tokenPartitions,
(vals, type, isScalar) => TypeConverter.ChangeType(vals, type, isScalar, CultureInfo.InvariantCulture, false),
StringComparer.Ordinal
);
// Verify outcome
Assert.NotNull(((Ok<IEnumerable<SpecificationProperty>, Error>)result).Success.Single(
a => a.Specification.IsOption()
&& ((OptionSpecification)a.Specification).ShortName.Equals("x")
&& (bool)((Just<object>)a.Value).Value));
// Teardown
}