本文整理汇总了C#中System.Reflection.MemberInfo.GetMemberValueType方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.GetMemberValueType方法的具体用法?C# MemberInfo.GetMemberValueType怎么用?C# MemberInfo.GetMemberValueType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MemberInfo
的用法示例。
在下文中一共展示了MemberInfo.GetMemberValueType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsReadOnlyAppendableCollectionMember
public static bool IsReadOnlyAppendableCollectionMember( MemberInfo memberInfo )
{
Contract.Requires( memberInfo != null );
if ( memberInfo.CanSetValue() )
{
// Not read only
return false;
}
Type memberValueType = memberInfo.GetMemberValueType();
if ( memberValueType.IsArray )
{
// Not appendable
return false;
}
CollectionTraits traits = memberValueType.GetCollectionTraits();
return traits.CollectionType != CollectionKind.NotCollection && traits.AddMethod != null;
}
示例2: EmitDeserializeValue
public static void EmitDeserializeValue( SerializerEmitter emitter, TracingILGenerator il, int unpackerArgumentIndex, LocalBuilder result, MemberInfo member, string memberName, NilImplication nilImplication, Action<TracingILGenerator, int> customUnpackerReading )
{
Contract.Requires( emitter != null );
Contract.Requires( il != null );
Contract.Requires( unpackerArgumentIndex >= 0 );
Contract.Requires( result != null );
Contract.Requires( member != null );
if ( customUnpackerReading != null )
{
customUnpackerReading( il, unpackerArgumentIndex );
}
var endOfDeserialization = il.DefineLabel( "END_OF_DESERIALIZATION" );
if ( memberName != null )
{
EmitNilImplication( il, unpackerArgumentIndex, memberName, nilImplication, endOfDeserialization );
}
/*
*
* if( !unpacker.IsArrayHeader && !unpacker.IsMapHeader )
* {
* valueN = GET_SERIALIZER.UnpackFrom( unpacker );
* }
* else
* {
* using( var subtreeUnpacker = unpacker.ReadSubtree )
* {
* valueN = GET_SERIALIZER.UnpackFrom( unpacker );
* }
* }
*
* isValueNUnpacked = true;
* END_OF_DESERIALIZATION:
*/
var then = il.DefineLabel( "THEN" );
var endIf = il.DefineLabel( "END_IF" );
var value = il.DeclareLocal( member.GetMemberValueType(), "value" );
var serializerGetter = emitter.RegisterSerializer( value.LocalType );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.IsArrayHeader );
il.EmitBrtrue_S( then );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.IsMapHeader );
il.EmitBrtrue_S( then );
// else
serializerGetter( il, 0 );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitAnyCall( typeof( MessagePackSerializer<> ).MakeGenericType( value.LocalType ).GetMethod( "UnpackFrom" ) );
il.EmitAnyStloc( value );
il.EmitBr_S( endIf );
// then
var subtreeUnpacker = il.DeclareLocal( typeof( Unpacker ), "subtreeUnpacker" );
il.MarkLabel( then );
EmitUnpackerBeginReadSubtree( il, unpackerArgumentIndex, subtreeUnpacker );
serializerGetter( il, 0 );
il.EmitAnyLdloc( subtreeUnpacker );
il.EmitAnyCall( typeof( MessagePackSerializer<> ).MakeGenericType( value.LocalType ).GetMethod( "UnpackFrom" ) );
il.EmitAnyStloc( value );
EmitUnpackerEndReadSubtree( il, subtreeUnpacker );
il.MarkLabel( endIf );
if ( result.LocalType.IsValueType )
{
il.EmitAnyLdloca( result );
}
else
{
il.EmitAnyLdloc( result );
}
il.EmitAnyLdloc( value );
Emittion.EmitStoreValue( il, member );
il.MarkLabel( endOfDeserialization );
}