本文整理匯總了C#中MsgPack.Serialization.Reflection.TracingILGenerator.EmitLdtoken方法的典型用法代碼示例。如果您正苦於以下問題:C# TracingILGenerator.EmitLdtoken方法的具體用法?C# TracingILGenerator.EmitLdtoken怎麽用?C# TracingILGenerator.EmitLdtoken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MsgPack.Serialization.Reflection.TracingILGenerator
的用法示例。
在下文中一共展示了TracingILGenerator.EmitLdtoken方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: EmitNilImplicationForPrimitive
private static void EmitNilImplicationForPrimitive( TracingILGenerator il, SerializingMember member, LocalBuilder value, Label endOfDeserialization )
{
var endIf = il.DefineLabel( "END_IF_NULL" );
EmitCompareNull( il, value, endIf );
switch ( member.Contract.NilImplication )
{
case NilImplication.MemberDefault:
{
/*
* if( value == null )
* {
* // Skip current.
* goto END_OF_DESERIALIZATION;
* }
*/
il.EmitBr( endOfDeserialization );
break;
}
case NilImplication.Null:
{
// Throw exception for non-nullable value type.
// Nop for nullables.
if ( member.Member.GetMemberValueType().GetIsValueType()
&& Nullable.GetUnderlyingType( member.Member.GetMemberValueType() ) == null )
{
/*
* if( value == null )
* {
* throw SerializationEceptions.NewValueTypeCannotBeNull( "...", typeof( MEMBER ), typeof( TYPE ) );
* }
*/
il.EmitLdstr( member.Contract.Name );
il.EmitLdtoken( member.Member.GetMemberValueType() );
il.EmitAnyCall( Metadata._Type.GetTypeFromHandle );
il.EmitLdtoken( member.Member.DeclaringType );
il.EmitAnyCall( Metadata._Type.GetTypeFromHandle );
il.EmitAnyCall( SerializationExceptions.NewValueTypeCannotBeNull3Method );
il.EmitThrow();
}
break;
}
case NilImplication.Prohibit:
{
/*
* if( value == null )
* {
* throw SerializationEceptions.NewProhibitNullException( "..." );
* }
*/
il.EmitLdstr( member.Contract.Name );
il.EmitAnyCall( SerializationExceptions.NewNullIsProhibitedMethod );
il.EmitThrow();
break;
}
}
il.MarkLabel( endIf );
}