Exemple #1
0
 internal void CastToObject(Type type)
 {
     if (CompilerContext.IsObject(type))
     {
         return;
     }
     if (type.IsValueType)
     {
         this.il.Emit(OpCodes.Box, type);
         return;
     }
     this.il.Emit(OpCodes.Castclass, this.MapType(typeof(object)));
 }
Exemple #2
0
 internal void CastFromObject(Type type)
 {
     if (CompilerContext.IsObject(type))
     {
         return;
     }
     if (!type.IsValueType)
     {
         this.il.Emit(OpCodes.Castclass, type);
         return;
     }
     if (this.MetadataVersion != CompilerContext.ILVersion.Net1)
     {
         this.il.Emit(OpCodes.Unbox_Any, type);
         return;
     }
     this.il.Emit(OpCodes.Unbox, type);
     this.il.Emit(OpCodes.Ldobj, type);
 }