예제 #1
0
 // Get the token for a field within this module.  Returns
 // a member reference if the constructor is in another assembly.
 public FieldToken GetFieldToken(FieldInfo field)
 {
     if (field == null)
     {
         throw new ArgumentNullException("field");
     }
     else if (field is FieldBuilder)
     {
         FieldBuilder fb = (field as FieldBuilder);
         if (fb.type.module == this)
         {
             return(fb.GetToken());
         }
     }
     else if (field is ClrField)
     {
         lock (typeof(AssemblyBuilder))
         {
             return(new FieldToken
                        (TypeBuilder.ClrTypeImportMember
                            (privateData, ((ClrField)field).ClrHandle)));
         }
     }
     throw new InvalidOperationException(_("Emit_CannotImportItem"));
 }