Ejemplo n.º 1
0
        private byte[] GenerateResource()
        {
            using (var writer = new StringWriter())
                using (var resx = new ResXResourceWriter(writer))
                {
                    resx.AddAlias("System.Windows.Forms", new AssemblyName("System.Windows.Forms"));
                    resx.AddResource(new ResXDataNode("110", _manifest.Name));
                    resx.AddResource(new ResXDataNode("112", _manifest.Description));

                    if (!string.IsNullOrEmpty(_manifest.Icon))
                    {
                        string iconFileName = Path.GetFileNameWithoutExtension(InputFilePath) + ".ico";

                        var fileRef = new ResXFileRef(iconFileName, "System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
                        resx.AddResource(new ResXDataNode("400", fileRef));
                    }

                    resx.Generate();
                    writer.Flush();

                    var sb = writer.GetStringBuilder();
                    return(Encoding.UTF8.GetBytes(sb.ToString()));
                }
        }