Author: zoltan
Date: 2006-05-15 14:03:39 -0400 (Mon, 15 May 2006)
New Revision: 60712
Modified:
trunk/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
trunk/mcs/class/corlib/System.Reflection.Emit/ChangeLog
trunk/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
Log:
2006-05-15 Zoltan Varga <[EMAIL PROTECTED]>
* AssemblyBuilder.cs (MonoResource): Add a 'stream' field.
* ModuleBuilder.cs (DefineManifestResource): Add new net 2.0 method.
Modified: trunk/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
===================================================================
--- trunk/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
2006-05-15 18:01:06 UTC (rev 60711)
+++ trunk/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
2006-05-15 18:03:39 UTC (rev 60712)
@@ -65,6 +65,7 @@
public string filename;
public ResourceAttributes attrs;
public int offset;
+ public Stream stream;
}
internal struct MonoWin32Resource {
Modified: trunk/mcs/class/corlib/System.Reflection.Emit/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Reflection.Emit/ChangeLog 2006-05-15
18:01:06 UTC (rev 60711)
+++ trunk/mcs/class/corlib/System.Reflection.Emit/ChangeLog 2006-05-15
18:03:39 UTC (rev 60712)
@@ -1,3 +1,9 @@
+2006-05-15 Zoltan Varga <[EMAIL PROTECTED]>
+
+ * AssemblyBuilder.cs (MonoResource): Add a 'stream' field.
+
+ * ModuleBuilder.cs (DefineManifestResource): Add new net 2.0 method.
+
2006-04-26 Miguel de Icaza <[EMAIL PROTECTED]>
* MethodBuilder.cs: better error messages when we close the
Modified: trunk/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
===================================================================
--- trunk/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
2006-05-15 18:01:06 UTC (rev 60711)
+++ trunk/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
2006-05-15 18:03:39 UTC (rev 60712)
@@ -510,6 +510,33 @@
throw new NotImplementedException ();
}
+#if NET_2_0
+ public void DefineManifestResource (string name, Stream stream,
ResourceAttributes attribute) {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ if (name == String.Empty)
+ throw new ArgumentException ("name cannot be
empty");
+ if (stream == null)
+ throw new ArgumentNullException ("stream");
+ if (transient)
+ throw new InvalidOperationException ("The
module is transient");
+ if (!assemblyb.IsSave)
+ throw new InvalidOperationException ("The
assembly is transient");
+
+ 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;
+ resources [p].stream = stream;
+ }
+#endif
+
[MonoTODO]
public void SetSymCustomAttribute (string name, byte[] data)
{
@@ -662,6 +689,24 @@
}
}
+ if (resources != null) {
+ for (int i = 0; i < resources.Length; ++i) {
+ Stream stream = resources [i].stream;
+
+ // According to MSDN docs, the stream
is read during assembly save, not earlier
+ if (stream != null) {
+ try {
+ long len =
stream.Length;
+ resources [i].data =
new byte [len];
+ stream.Seek (0,
SeekOrigin.Begin);
+ stream.Read (resources
[i].data, 0, (int)len);
+ } catch {
+ /* do something */
+ }
+ }
+ }
+ }
+
build_metadata (this);
string fileName = fqname;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches