Beispiel #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"));
 }
Beispiel #2
0
 // Get the token for a method within this module.  Returns
 // a member reference if the constructor is in another assembly.
 public MethodToken GetMethodToken(MethodInfo method)
 {
     if (method == null)
     {
         throw new ArgumentNullException("method");
     }
     else if (method is MethodBuilder)
     {
         MethodBuilder mb = (method as MethodBuilder);
         if (mb.type.module == this)
         {
             return(mb.GetToken());
         }
     }
     else if (method is ClrMethod)
     {
         lock (typeof(AssemblyBuilder))
         {
             return(new MethodToken
                        (TypeBuilder.ClrTypeImportMember
                            (privateData, ((ClrMethod)method).ClrHandle)));
         }
     }
     throw new InvalidOperationException(_("Emit_CannotImportItem"));
 }
Beispiel #3
0
 // Get the token for a constructor within this module.  Returns
 // a member reference if the constructor is in another assembly.
 public MethodToken GetConstructorToken(ConstructorInfo con)
 {
     if (con == null)
     {
         throw new ArgumentNullException("con");
     }
     else if (con is ConstructorBuilder)
     {
         ConstructorBuilder cb = (con as ConstructorBuilder);
         if (cb.type.module == this)
         {
             return(cb.GetToken());
         }
     }
     else if (con is ClrConstructor)
     {
         lock (typeof(AssemblyBuilder))
         {
             return(new MethodToken
                        (TypeBuilder.ClrTypeImportMember
                            (privateData, ((ClrConstructor)con).ClrHandle)));
         }
     }
     throw new InvalidOperationException(_("Emit_CannotImportItem"));
 }