+ }
+
+ class Resources
+ {
+ interface IResource
+ {
+ void Emit ();
+ string FileName { get; }
+ }
+
+ class EmbededResource : IResource
+ {
+ static MethodInfo embed_res;
+
+ static EmbededResource () {
+ Type[] argst = new Type [] {
+ typeof (string), typeof (string), typeof (ResourceAttributes)
+ };
+
+ embed_res = typeof (AssemblyBuilder).GetMethod (
+ "EmbedResourceFile", BindingFlags.Instance|BindingFlags.Public|BindingFlags.NonPublic,
+ null, CallingConventions.Any, argst, null);
+
+ if (embed_res == null) {
+ Report.RuntimeMissingSupport (Location.Null, "Resource embedding");
+ }
+ }
+
+ readonly object[] args;
+
+ public EmbededResource (string name, string file, bool isPrivate)
+ {
+ args = new object [3];
+ args [0] = name;
+ args [1] = file;
+ args [2] = isPrivate ? ResourceAttributes.Private : ResourceAttributes.Public;
+ }
+
+ public void Emit()
+ {
+ embed_res.Invoke (CodeGen.Assembly.Builder, args);
+ }
+
+ public string FileName {
+ get {
+ return (string)args [1];
+ }
+ }
+ }
+
+ class LinkedResource : IResource
+ {
+ readonly string file;
+ readonly string name;
+ readonly ResourceAttributes attribute;
+
+ public LinkedResource (string name, string file, bool isPrivate)
+ {
+ this.name = name;
+ this.file = file;
+ this.attribute = isPrivate ? ResourceAttributes.Private : ResourceAttributes.Public;
+ }
+
+ public void Emit ()
+ {
+ CodeGen.Assembly.Builder.AddResourceFile (name, file, attribute);
+ }
+
+ public string FileName {
+ get {
+ return file;
+ }
+ }
+ }
+