+ public IResourceWriter DefineResource (string name, string description, ResourceAttributes attribute)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ if (name == String.Empty)
+ throw new ArgumentException ("name cannot be empty");
+ if (transient)
+ throw new InvalidOperationException ("The module is transient");
+ if (!assemblyb.IsSave)
+ throw new InvalidOperationException ("The assembly is transient");
+ ResourceWriter writer = new ResourceWriter (new MemoryStream ());
+ if (resource_writers == null)
+ resource_writers = new ArrayList ();
+ resource_writers.Add (writer);
+
+ // The data is filled out later
+ if (resources != null) {
+ MonoResource[] new_r = new MonoResource [resources.Length + 1];
+ System.Array.Copy(resources, new_r, resources.Length);
+ resources = new_r;
+ } else {
+ resources = new MonoResource [1];
+ }
+ int p = resources.Length - 1;
+ resources [p].name = name;
+ resources [p].attrs = attribute;
+
+ return writer;
+ }
+
+ public IResourceWriter DefineResource (string name, string description)
+ {
+ return DefineResource (name, description, ResourceAttributes.Public);
+ }
+
+ [MonoTODO]
+ public void DefineUnmanagedResource (byte[] resource)
+ {
+ if (resource == null)
+ throw new ArgumentNullException ("resource");
+
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void DefineUnmanagedResource (string resourceFileName)
+ {
+ if (resourceFileName == null)
+ throw new ArgumentNullException ("resourceFileName");
+ if (resourceFileName == String.Empty)
+ throw new ArgumentException ("resourceFileName");
+ if (!File.Exists (resourceFileName) || Directory.Exists (resourceFileName))
+ throw new FileNotFoundException ("File '" + resourceFileName + "' does not exists or is a directory.");
+
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetSymCustomAttribute (string name, byte[] data)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public void SetUserEntryPoint (MethodInfo entryPoint)
+ {
+ if (entryPoint == null)
+ throw new ArgumentNullException ("entryPoint");
+ if (entryPoint.DeclaringType.Module != this)
+ throw new InvalidOperationException ("entryPoint is not contained in this module");
+ throw new NotImplementedException ();
+ }
+
+ public MethodToken GetMethodToken (MethodInfo method)
+ {
+ if (method == null)
+ throw new ArgumentNullException ("method");
+ if (method.DeclaringType.Module != this)
+ throw new InvalidOperationException ("The method is not in this module");
+ return new MethodToken (GetToken (method));
+ }
+
+ public MethodToken GetArrayMethodToken (Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
+ {
+ return GetMethodToken (GetArrayMethod (arrayClass, methodName, callingConvention, returnType, parameterTypes));
+ }
+
+
+ public MethodToken GetConstructorToken (ConstructorInfo con)
+ {
+ if (con == null)
+ throw new ArgumentNullException ("con");
+ return new MethodToken (GetToken (con));
+ }
+
+ public FieldToken GetFieldToken (FieldInfo field)
+ {
+ if (field == null)
+ throw new ArgumentNullException ("field");
+ if (field.DeclaringType.Module != this)
+ throw new InvalidOperationException ("The method is not in this module");
+ return new FieldToken (GetToken (field));
+ }
+
+ [MonoTODO]
+ public SignatureToken GetSignatureToken (byte[] sigBytes, int sigLength)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public SignatureToken GetSignatureToken (SignatureHelper sigHelper)
+ {
+ if (sigHelper == null)
+ throw new ArgumentNullException ("sigHelper");
+ return new SignatureToken (GetToken (sigHelper));
+ }
+
+ public StringToken GetStringConstant (string str)
+ {
+ if (str == null)
+ throw new ArgumentNullException ("str");
+ return new StringToken (GetToken (str));
+ }
+
+ public TypeToken GetTypeToken (Type type)
+ {
+ if (type == null)
+ throw new ArgumentNullException ("type");
+ if (type.IsByRef)
+ throw new ArgumentException ("type can't be a byref type", "type");
+ if (!IsTransient () && (type.Module is ModuleBuilder) && ((ModuleBuilder)type.Module).IsTransient ())
+ throw new InvalidOperationException ("a non-transient module can't reference a transient module");
+ return new TypeToken (GetToken (type));
+ }
+
+ public TypeToken GetTypeToken (string type)
+ {
+ return GetTypeToken (GetType (name));
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern int getUSIndex (ModuleBuilder mb, string str);
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern int getToken (ModuleBuilder mb, object obj);
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern int getMethodToken (ModuleBuilder mb, MethodInfo method,
+ Type[] opt_param_types);
+
+ internal int GetToken (string str) {
+ if (us_string_cache.Contains (str))
+ return (int)us_string_cache [str];
+ int result = getUSIndex (this, str);
+ us_string_cache [str] = result;
+ return result;
+ }
+
+ internal int GetToken (MemberInfo member) {
+ return getToken (this, member);
+ }
+
+ internal int GetToken (MethodInfo method, Type[] opt_param_types) {
+ return getMethodToken (this, method, opt_param_types);
+ }
+
+ internal int GetToken (SignatureHelper helper) {
+ return getToken (this, helper);
+ }
+
+ internal TokenGenerator GetTokenGenerator () {
+ if (token_gen == null)
+ token_gen = new ModuleBuilderTokenGenerator (this);
+ return token_gen;
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern void build_metadata (ModuleBuilder mb);
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private extern void WriteToFile (IntPtr handle);
+