本文整理汇总了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 );
}