本文整理汇总了C#中Property.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# Property.GetValues方法的具体用法?C# Property.GetValues怎么用?C# Property.GetValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property.GetValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValues_WhenDeepGraphWithEnumerables_CanExtractValues
public void GetValues_WhenDeepGraphWithEnumerables_CanExtractValues()
{
var ordersPropertyInfo = typeof(TestCustomer).GetProperty("Orders");
var ordersProperty = new Property(ordersPropertyInfo);
var linesPropertyInfo = typeof(TestOrder).GetProperty("Lines");
var linesProperty = new Property(1, ordersProperty, linesPropertyInfo);
var prodNoPropertyInfo = typeof(TestOrderLine).GetProperty("ProductNo");
var prodNoProperty = new Property(2, linesProperty, prodNoPropertyInfo);
var graph = new TestCustomer
{
Orders =
{
new TestOrder
{
Lines =
{
new TestOrderLine { ProductNo = "P1", Quantity = 1 },
new TestOrderLine { ProductNo = "P2", Quantity = 2 }
}
}
}
};
var values = prodNoProperty.GetValues(graph);
CollectionAssert.AreEqual(new[] { "P1", "P2" }, values);
}
示例2: GetValues_WhenSingleStringMember_SingleValueIsReturned
public void GetValues_WhenSingleStringMember_SingleValueIsReturned()
{
var propertyInfo = typeof(TestCustomer).GetProperty("CustomerNo");
var property = new Property(propertyInfo);
var customer = new TestCustomer { CustomerNo = "1234" };
var customerNos = property.GetValues(customer);
CollectionAssert.AreEqual(new[] {"1234"}, customerNos);
}
示例3: GetValues_WhenArrayOfInt_ReturnsAValueArray
public void GetValues_WhenArrayOfInt_ReturnsAValueArray()
{
var propertyInfo = typeof(TestCustomer).GetProperty("Points");
var property = new Property(propertyInfo);
var container = new TestCustomer { Points = new[] { 5, 4, 3, 2, 1 } };
var values = property.GetValues(container);
CollectionAssert.AreEqual(new[] { 5, 4, 3, 2, 1 }, values);
}