本文整理汇总了C#中Person.CreateFastPropertyGetter方法的典型用法代码示例。如果您正苦于以下问题:C# Person.CreateFastPropertyGetter方法的具体用法?C# Person.CreateFastPropertyGetter怎么用?C# Person.CreateFastPropertyGetter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person.CreateFastPropertyGetter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ObjectExtensions_CreateFastPropertyGetter_untyped_using_valid_property_should_create_a_valid_getter
public void ObjectExtensions_CreateFastPropertyGetter_untyped_using_valid_property_should_create_a_valid_getter()
{
var expected = "Mauro";
var person = new Person() { Name = expected };
var getter = person.CreateFastPropertyGetter( typeof( Person ).GetProperty( "Name" ) );
var actual = ( String )getter.DynamicInvoke();
actual.Should().Be.EqualTo( expected );
}
示例2: ObjectExtensions_CreateFastPropertyGetter_typed_using_private_property_should_create_a_valid_getter
public void ObjectExtensions_CreateFastPropertyGetter_typed_using_private_property_should_create_a_valid_getter()
{
var expected = "Mauro";
var person = new Person( expected );
var getter = person.CreateFastPropertyGetter<String>( typeof( Person ).GetProperty( "privateValue", BindingFlags.NonPublic | BindingFlags.Instance ) );
var actual = getter();
actual.Should().Be.EqualTo( expected );
}
示例3: ObjectExtensions_CreateFastPropertyGetter_typed_using_valid_property_should_create_a_valid_getter
public void ObjectExtensions_CreateFastPropertyGetter_typed_using_valid_property_should_create_a_valid_getter()
{
var expected = "Mauro";
var person = new Person() { Name = expected };
var getter = person.CreateFastPropertyGetter<String>( "Name" );
var actual = getter();
actual.Should().Be.EqualTo( expected );
}
示例4: Person
public void ObjectExtensions_CreateFastPropertyGetter_untyped_using_valuetype_property_should_create_a_valid_getter()
{
//Do not sincerly know if there is a way to make it work as expected.
var expected = 10;
var person = new Person();
person.Age = expected;
//AFAIK there is no way to make type inference work.
var getter = person.CreateFastPropertyGetter( typeof( Person ).GetProperty( "Age" ) );
var actual = getter();
actual.Should().Be.EqualTo( expected );
}