Beispiel #1
0
        public static Uri GetPlatformUri()
        {
            spritesReader.GetResourceData("platform", out _, out byte[] data);

            return(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\.." +
                           System.Text.Encoding.UTF8.GetString(data).Substring(1)));
        }
        public void GetResourceData2()
        {
            byte [] expected = new byte [] {
                0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
                0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x51, 0x53,
                0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x44, 0x72,
                0x61, 0x77, 0x69, 0x6E, 0x67, 0x2C, 0x20, 0x56,
                0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x32,
                0x2E, 0x30, 0x2E, 0x30, 0x2E, 0x30, 0x2C, 0x20,
                0x43, 0x75, 0x6C, 0x74, 0x75, 0x72, 0x65, 0x3D,
                0x6E, 0x65, 0x75, 0x74, 0x72, 0x61, 0x6C, 0x2C,
                0x20, 0x50, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x4B,
                0x65, 0x79, 0x54, 0x6F, 0x6B, 0x65, 0x6E, 0x3D,
                0x62, 0x30, 0x33, 0x66, 0x35, 0x66, 0x37, 0x66,
                0x31, 0x31, 0x64, 0x35, 0x30, 0x61, 0x33, 0x61,
                0x05, 0x01, 0x00, 0x00, 0x00, 0x13, 0x53, 0x79,
                0x73, 0x74, 0x65, 0x6D, 0x2E, 0x44, 0x72, 0x61,
                0x77, 0x69, 0x6E, 0x67, 0x2E, 0x53, 0x69, 0x7A,
                0x65, 0x02, 0x00, 0x00, 0x00, 0x05, 0x77, 0x69,
                0x64, 0x74, 0x68, 0x06, 0x68, 0x65, 0x69, 0x67,
                0x68, 0x74, 0x00, 0x00, 0x08, 0x08, 0x02, 0x00,
                0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00,
                0x00, 0x00, 0x0B
            };
            ResourceReader r = new ResourceReader("Test/resources/bug81759.resources");
            string         type;

            byte [] bytes;
            r.GetResourceData("imageList.ImageSize", out type, out bytes);
            // Note that const should not be used here.
            Assert.AreEqual("System.Drawing.Size, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", type, "#1");
            Assert.AreEqual(expected, bytes, "#2");
            r.Close();
        }
Beispiel #3
0
        private void ParseResource(EmbeddedResource resource)
        {
            ResourceReader reader;

            try
            {
                reader = new ResourceReader(resource.CreateReader().AsStream());
            }
            catch (ArgumentException)
            {
                Console.WriteLine("This resource can not be parsed.");
                //throw;
                return;
            }

            var e = reader.GetEnumerator();

            while (e.MoveNext())
            {
                if (e.Key.ToString().ToLower().EndsWith(".baml"))
                {
                    reader.GetResourceData(e.Key.ToString(), out _, out var contents);

                    //MARK:AF 3E 00 00
                    contents = contents.Skip(4).ToArray(); //MARK:the first 4 bytes = length
                    using (var ms = new MemoryStream(contents))
                    {
                        BamlDocument b = BamlReader.ReadDocument(ms);
                        BamlFiles.TryAdd(e.Key.ToString(), b);
                    }
                }
            }
        }
        // given a resource path (TestWebServer.Properties.Resources) from an assembly and a resource name (without the extension) get the object item.
        // the resourceext is the common extension given to the resource path.

        public static Object GetResource(this Assembly ass, string resource, string item, string resourceext = ".resources")
        {
            try
            {
                string final = resource + resourceext;
                using (var st = ass.GetManifestResourceStream(final))
                {
                    if (st != null)
                    {
                        using (ResourceReader rr = new ResourceReader(st))
                        {
                            // you can enumerate, which gives the values directly, but you can't lookup by name.. stupid.
                            //IDictionaryEnumerator dict = rr.GetEnumerator();  while (dict.MoveNext())  System.Diagnostics.Debug.WriteLine("   {0}: '{1}' (Type {2})", dict.Key, dict.Value, dict.Value.GetType().Name);

                            rr.GetResourceData(item, out string restype, out byte[] rawdata); // will except if not there

                            using (MemoryStream ms = new MemoryStream(rawdata))               // convert to memory stream
                            {
                                BinaryFormatter formatter = new BinaryFormatter();            // resources seem
                                return(formatter.Deserialize(ms));                            // and deserialise object out
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Resource " + resource + "." + item + " Exception" + e);
            }

            return(null);
        }
        public void GetResourceData()
        {
            byte [] t1 = new byte [] { 0x16, 0x00, 0x00, 0x00, 0x76, 0x65, 0x72, 0x69, 0x74, 0x61, 0x73, 0x20, 0x76, 0x6F, 0x73, 0x20, 0x6C, 0x69, 0x62, 0x65, 0x72, 0x61, 0x62, 0x69, 0x74, 0x0A };
            byte [] t2 = new byte [] { 0x0A, 0x73, 0x6F, 0x6D, 0x65, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67 };
            byte [] t3 = new byte [] { 0x0E, 0x00, 0x00, 0x00, 0x73, 0x68, 0x61, 0x72, 0x64, 0x65, 0x6E, 0x66, 0x72, 0x65, 0x75, 0x64, 0x65, 0x0A };

            ResourceReader r     = new ResourceReader("Test/resources/StreamTest.resources");
            Hashtable      items = new Hashtable();

            foreach (DictionaryEntry de in r)
            {
                string  type;
                byte [] bytes;
                r.GetResourceData((string)de.Key, out type, out bytes);
                items [de.Key] = new DictionaryEntry(type, bytes);
            }

            DictionaryEntry p = (DictionaryEntry)items ["test"];

            Assert.AreEqual("ResourceTypeCode.Stream", p.Key as string, "#1-1");
            Assert.AreEqual(t1, p.Value as byte [], "#1-2");

            p = (DictionaryEntry)items ["test2"];
            Assert.AreEqual("ResourceTypeCode.String", p.Key as string, "#2-1");
            Assert.AreEqual(t2, p.Value as byte [], "#2-2");

            p = (DictionaryEntry)items ["test3"];
            Assert.AreEqual("ResourceTypeCode.ByteArray", p.Key as string, "#3-1");
            Assert.AreEqual(t3, p.Value as byte [], "#3-2");

            r.Close();
        }
Beispiel #6
0
        public static Image RecuperarImagenDeArchivoDeRecursos(string nombreImagen)
        {
            Image imagen;

            try
            {
                using (ResourceReader rr = new ResourceReader(@".\Recursos.resources"))
                {
                    string tipoRecurso = "";
                    byte[] bytesArchivo;
                    rr.GetResourceData(nombreImagen, out tipoRecurso, out bytesArchivo);
                    const int OFFSET    = 4;
                    int       size      = BitConverter.ToInt32(bytesArchivo, 0);
                    Bitmap    imagenBMP = new Bitmap(new MemoryStream(bytesArchivo, OFFSET, size));
                    imagen = imagenBMP;
                }
                return(imagen);
            }
            catch
            { //si no encuentra una imagen, cuando se ejecuta por primera vez, o si borraron
              //accidentalmente el archivo de recursos, crea un nuevo archivo de recursos
                using (ResourceWriter rw = new ResourceWriter(@".\Recursos.resources"))
                {
                    rw.AddResource("Sistema", "Inmobiliaria");
                }
                return(null);
            }
        }
Beispiel #7
0
        public void GetResourceDataNullName()
        {
            ResourceReader r = new ResourceReader("Test/resources/StreamTest.resources");
            string         type;

            byte [] bytes;

            try
            {
                r.GetResourceData(null, out type, out bytes);
                Assert.Fail("#1");
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual(typeof(ArgumentNullException), ex.GetType(), "#2");
                Assert.IsNull(ex.InnerException, "#3");
                Assert.IsNotNull(ex.Message, "#4");
                Assert.IsNotNull(ex.ParamName, "#5");
                Assert.AreEqual("resourceName", ex.ParamName, "#6");
            }
            finally
            {
                r.Close();
            }
        }
Beispiel #8
0
        private void build_page_1()
        {
            TextView tv1 = new TextView();

            try
            {
                string         rez          = "Adeptus.Resources.resources";
                string         key          = "mystring1";
                string         resourceType = "";
                byte[]         resourceData;
                ResourceReader r = new ResourceReader(rez);
                r.GetResourceData(key, out resourceType, out resourceData);
                r.Close();
                System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                tv1.Buffer.Text = enc.GetString(resourceData);
            }
            catch (Exception exp)
            {
                tv1.Buffer.Text = exp.Message;
            }

            tv1.WrapMode = WrapMode.Word;
            tv1.Editable = false;

            this.AppendPage(tv1);
            this.SetPageTitle(tv1, "Introduction");
            this.SetPageType(tv1, AssistantPageType.Intro);
            this.SetPageComplete(tv1, true);
        }
Beispiel #9
0
        static ChineseChar()
        {
            Assembly executingAssembly = Assembly.GetExecutingAssembly();

            using (Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("Microsoft.International.Converters.PinYinConverter.PinyinDictionary.resources"))
            {
                using (ResourceReader resourceReader = new ResourceReader(manifestResourceStream))
                {
                    string text;
                    byte[] buffer;
                    resourceReader.GetResourceData("PinyinDictionary", out text, out buffer);
                    using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer)))
                    {
                        ChineseChar.pinyinDictionary = PinyinDictionary.Deserialize(binaryReader);
                    }
                }
            }
            using (Stream manifestResourceStream2 = executingAssembly.GetManifestResourceStream("Microsoft.International.Converters.PinYinConverter.CharDictionary.resources"))
            {
                using (ResourceReader resourceReader2 = new ResourceReader(manifestResourceStream2))
                {
                    string text;
                    byte[] buffer;
                    resourceReader2.GetResourceData("CharDictionary", out text, out buffer);
                    using (BinaryReader binaryReader2 = new BinaryReader(new MemoryStream(buffer)))
                    {
                        ChineseChar.charDictionary = CharDictionary.Deserialize(binaryReader2);
                    }
                }
            }
            using (Stream manifestResourceStream3 = executingAssembly.GetManifestResourceStream("Microsoft.International.Converters.PinYinConverter.HomophoneDictionary.resources"))
            {
                using (ResourceReader resourceReader3 = new ResourceReader(manifestResourceStream3))
                {
                    string text;
                    byte[] buffer;
                    resourceReader3.GetResourceData("HomophoneDictionary", out text, out buffer);
                    using (BinaryReader binaryReader3 = new BinaryReader(new MemoryStream(buffer)))
                    {
                        ChineseChar.homophoneDictionary = HomophoneDictionary.Deserialize(binaryReader3);
                    }
                }
            }
            using (Stream manifestResourceStream4 = executingAssembly.GetManifestResourceStream("Microsoft.International.Converters.PinYinConverter.StrokeDictionary.resources"))
            {
                using (ResourceReader resourceReader4 = new ResourceReader(manifestResourceStream4))
                {
                    string text;
                    byte[] buffer;
                    resourceReader4.GetResourceData("StrokeDictionary", out text, out buffer);
                    using (BinaryReader binaryReader4 = new BinaryReader(new MemoryStream(buffer)))
                    {
                        ChineseChar.strokeDictionary = StrokeDictionary.Deserialize(binaryReader4);
                    }
                }
            }
        }
        public void PostRename(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def)
        {
            var module = def as ModuleDefMD;

            if (module == null)
            {
                return;
            }

            var wpfResInfo = context.Annotations.Get <Dictionary <string, Dictionary <string, BamlDocument> > >(module, BAMLKey);

            if (wpfResInfo == null)
            {
                return;
            }

            foreach (var res in module.Resources.OfType <EmbeddedResource>())
            {
                Dictionary <string, BamlDocument> resInfo;

                if (!wpfResInfo.TryGetValue(res.Name, out resInfo))
                {
                    continue;
                }

                var stream = new MemoryStream();
                var writer = new ResourceWriter(stream);

                res.Data.Position = 0;
                var reader     = new ResourceReader(new ImageStream(res.Data));
                var enumerator = reader.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var    name = (string)enumerator.Key;
                    string typeName;
                    byte[] data;
                    reader.GetResourceData(name, out typeName, out data);

                    BamlDocument document;
                    if (resInfo.TryGetValue(name, out document))
                    {
                        var docStream = new MemoryStream();
                        docStream.Position = 4;
                        BamlWriter.WriteDocument(document, docStream);
                        docStream.Position = 0;
                        docStream.Write(BitConverter.GetBytes((int)docStream.Length - 4), 0, 4);
                        data = docStream.ToArray();
                        name = document.DocumentName;
                    }

                    writer.AddResourceData(name, typeName, data);
                }
                writer.Generate();
                res.Data = MemoryImageStream.Create(stream.ToArray());
            }
        }
Beispiel #11
0
    /// <summary>
    /// Adds a given resourcename and data to the app resources in the target assembly
    /// </summary>
    /// <param name="ResourceName"></param>
    /// <param name="ResourceData"></param>
    /// <remarks></remarks>
    public void Add(string ResourceName, byte[] ResourceData)
    {
        // make sure the writer is initialized
        InitAssembly();

        // have to enumerate this way
        for (var x = 0; x <= _Resources.Count - 1; x++)
        {
            var res = _Resources[x];
            if (res.Name.Contains(".Resources.resources"))
            {
                // Have to assume this is the root application's .net resources.
                // That might not be the case though.

                // cast as embeded resource to get at the data
                var EmbededResource = (Mono.Cecil.EmbeddedResource)res;

                // a Resource reader is required to read the resource data
                var ResReader = new ResourceReader(new MemoryStream(EmbededResource.GetResourceData()));

                // Use this output stream to capture all the resource data from the
                // existing resource block, so we can add the new resource into it
                var    MemStreamOut  = new MemoryStream();
                var    ResWriter     = new System.Resources.ResourceWriter(MemStreamOut);
                var    ResEnumerator = ResReader.GetEnumerator();
                byte[] resdata       = null;
                while (ResEnumerator.MoveNext())
                {
                    var    resname = (string)ResEnumerator.Key;
                    string restype = "";
                    // if we come across a resource named the same as the one
                    // we're about to add, skip it
                    if (Strings.StrComp(resname, ResourceName, CompareMethod.Text) != 0)
                    {
                        ResReader.GetResourceData(resname, out restype, out resdata);
                        ResWriter.AddResourceData(resname, restype, resdata);
                    }
                }

                // add the new resource data here
                ResWriter.AddResourceData(ResourceName, "ResourceTypeCode.ByteArray", ResourceData);
                // gotta call this to render the memory stream
                ResWriter.Generate();

                // update the resource
                var buf         = MemStreamOut.ToArray();
                var NewEmbedRes = new EmbeddedResource(res.Name, res.Attributes, buf);
                _Resources.Remove(res);
                _Resources.Add(NewEmbedRes);
                // gotta bail out, there can't be 2 embedded resource chunks, right?
                break;                 // TODO: might not be correct. Was : Exit For
            }
        }
    }
        public MainWindow()
        {
            InitializeComponent();

            var assembly = Assembly.GetExecutingAssembly();

            string fileContent = "";

            using (var stream = assembly.GetManifestResourceStream("AccessToResourceInProject.g.resources"))
            {
                if (stream != null)
                {
                    using (var rr = new ResourceReader(stream))
                    {
                        if (rr != null)
                        {
                            var resourceName = "textfiles/textfile1.txt";

                            //一つ目の方法
                            string type;
                            byte[] resourceData;
                            rr.GetResourceData(resourceName, out type, out resourceData);

                            if (resourceData != null)
                            {
                                fileContent = Encoding.UTF8.GetString(resourceData);
                            }


                            //二つ目の方法
                            foreach (DictionaryEntry resource in rr)
                            {
                                if ((string)resource.Key == resourceName)
                                {
                                    using (var sr = new StreamReader((Stream)resource.Value))
                                    {
                                        fileContent = sr.ReadToEnd();
                                    }
                                }
                            }


                            //@Zuishinさんに教えていただいた方法
                            var info = Application.GetResourceStream(new Uri("/TextFiles/TextFile1.txt", UriKind.Relative));
                            using (var sr = new StreamReader(info.Stream))
                            {
                                fileContent = sr.ReadToEnd();
                            }
                        }
                    }
                }
            }
        }
        public void copyFiles()
        {
            using (
                var msData =
                    (UnmanagedMemoryStream)
                    Assembly.GetExecutingAssembly().GetManifestResourceStream("updateSystemDotNet.Setup.setup.package")) {
                using (var resReader = new ResourceReader(msData)) {
                    //Dateimap einlesen
                    var    xmlMap  = new XmlDocument();
                    byte[] mapData = null;
                    string tempString;
                    resReader.GetResourceData("map", out tempString, out mapData);
                    using (var msMap = new MemoryStream(mapData)) {
                        using (var srMap = new StreamReader(msMap, Encoding.UTF8)) {
                            xmlMap.Load(srMap);
                        }
                    }

                    int totalFiles  = (xmlMap.SelectNodes("Files/File").Count);
                    int currentFile = 0;

                    //Dateien verarbeiten
                    foreach (XmlNode fileNode in xmlMap.SelectNodes("Files/File"))
                    {
                        byte[] compressedFileData = null;
                        resReader.GetResourceData(fileNode.SelectSingleNode("Id").InnerText, out tempString, out compressedFileData);
                        writeCompressedFile(
                            compressedFileData,
                            fileNode.SelectSingleNode("Directory").InnerText,
                            fileNode.SelectSingleNode("Filename").InnerText);

                        currentFile++;
                        if (fileProgressChanged != null)
                        {
                            fileProgressChanged(this, new ProgressChangedEventArgs(Percent(currentFile, totalFiles), null));
                        }
                    }
                }
            }
        }
Beispiel #14
0
        static ChineseChar()
        {
            string str;

            byte[]   buffer;
            Assembly executingAssembly = Assembly.GetExecutingAssembly();

            using (Stream stream = executingAssembly.GetManifestResourceStream("Shove.Properties.Microsoft.International.Converters.PinYinConverter.PinyinDictionary.resources"))
            {
                using (ResourceReader reader = new ResourceReader(stream))
                {
                    reader.GetResourceData("PinyinDictionary", out str, out buffer);
                    using (BinaryReader reader2 = new BinaryReader(new MemoryStream(buffer)))
                    {
                        pinyinDictionary = PinyinDictionary.Deserialize(reader2);
                    }
                }
            }
            using (Stream stream2 = executingAssembly.GetManifestResourceStream("Shove.Properties.Microsoft.International.Converters.PinYinConverter.CharDictionary.resources"))
            {
                using (ResourceReader reader3 = new ResourceReader(stream2))
                {
                    reader3.GetResourceData("CharDictionary", out str, out buffer);
                    using (BinaryReader reader4 = new BinaryReader(new MemoryStream(buffer)))
                    {
                        charDictionary = CharDictionary.Deserialize(reader4);
                    }
                }
            }
            using (Stream stream3 = executingAssembly.GetManifestResourceStream("Shove.Properties.Microsoft.International.Converters.PinYinConverter.HomophoneDictionary.resources"))
            {
                using (ResourceReader reader5 = new ResourceReader(stream3))
                {
                    reader5.GetResourceData("HomophoneDictionary", out str, out buffer);
                    using (BinaryReader reader6 = new BinaryReader(new MemoryStream(buffer)))
                    {
                        homophoneDictionary = HomophoneDictionary.Deserialize(reader6);
                    }
                }
            }
            using (Stream stream4 = executingAssembly.GetManifestResourceStream("Shove.Properties.Microsoft.International.Converters.PinYinConverter.StrokeDictionary.resources"))
            {
                using (ResourceReader reader7 = new ResourceReader(stream4))
                {
                    reader7.GetResourceData("StrokeDictionary", out str, out buffer);
                    using (BinaryReader reader8 = new BinaryReader(new MemoryStream(buffer)))
                    {
                        strokeDictionary = StrokeDictionary.Deserialize(reader8);
                    }
                }
            }
        }
        public bool Read()
        {
            if (!_enumerator.MoveNext())
            {
                return(false);
            }

            _name = _enumerator.Key.ToString();
            _reader.GetResourceData(_name, out _typeName, out _data);
            _typeCode = ResourceUtils.GetTypeCode(_typeName);

            return(true);
        }
Beispiel #16
0
        /// <summary>
        /// Bietet Zugriff auf die Resourcen in einem Updatepaket.
        /// </summary>
        /// <param name="packagePath">Der Pfad zu dem Updatepaket.</param>
        /// <param name="resID">Die ID der Resource die ausgelesen werden soll.</param>
        /// <returns>Gibt die Resource in Form eines ByteArrays zurück.</returns>
        protected byte[] accessUpdatePackage(string packagePath, string resID)
        {
            var resReader = new ResourceReader(packagePath);

            try {
                byte[] outData;
                string outType;
                resReader.GetResourceData(resID, out outType, out outData);
                return(outData);
            }
            finally {
                resReader.Close();
            }
        }
Beispiel #17
0
 public static bool ContainsResource(this ResourceReader @this, string resName)
 {
     try
     {
         string dummy1;
         byte[] dummy2;
         @this.GetResourceData(resName, out dummy1, out dummy2);
         return(true);
     }
     catch (ArgumentException)
     {
         return(false);
     }
 }
Beispiel #18
0
        static ChineseChar()
        {
            var executingAssembly = Assembly.GetExecutingAssembly();

            using (var manifestResourceStream = executingAssembly.GetManifestResourceStream("Dragon.Framework.Infrastructure.Pinyin.Resources.PinyinDictionary.resources"))
            {
                using (var resourceReader = new ResourceReader(manifestResourceStream ?? Stream.Null))
                {
                    resourceReader.GetResourceData("PinyinDictionary", out _, out var buffer);
                    using (var binaryReader = new BinaryReader(new MemoryStream(buffer)))
                    {
                        PinyinDictionary = PinyinDictionary.Deserialize(binaryReader);
                    }
                }
            }
            using (var manifestResourceStream2 = executingAssembly.GetManifestResourceStream("Dragon.Framework.Infrastructure.Pinyin.Resources.CharDictionary.resources"))
            {
                using (var resourceReader2 = new ResourceReader(manifestResourceStream2 ?? Stream.Null))
                {
                    resourceReader2.GetResourceData("CharDictionary", out _, out var buffer);
                    using (var binaryReader2 = new BinaryReader(new MemoryStream(buffer)))
                    {
                        CharDictionary = CharDictionary.Deserialize(binaryReader2);
                    }
                }
            }
            using (var manifestResourceStream3 = executingAssembly.GetManifestResourceStream("Dragon.Framework.Infrastructure.Pinyin.Resources.HomophoneDictionary.resources"))
            {
                using (var resourceReader3 = new ResourceReader(manifestResourceStream3 ?? Stream.Null))
                {
                    resourceReader3.GetResourceData("HomophoneDictionary", out _, out var buffer);
                    using (var binaryReader3 = new BinaryReader(new MemoryStream(buffer)))
                    {
                        HomophoneDictionary = HomophoneDictionary.Deserialize(binaryReader3);
                    }
                }
            }
            using (var manifestResourceStream4 = executingAssembly.GetManifestResourceStream("Dragon.Framework.Infrastructure.Pinyin.Resources.StrokeDictionary.resources"))
            {
                using (var resourceReader4 = new ResourceReader(manifestResourceStream4 ?? Stream.Null))
                {
                    resourceReader4.GetResourceData("StrokeDictionary", out _, out var buffer);
                    using (var binaryReader4 = new BinaryReader(new MemoryStream(buffer)))
                    {
                        StrokeDictionary = StrokeDictionary.Deserialize(binaryReader4);
                    }
                }
            }
        }
        private void AnalyzeResources(ConfuserContext context, INameService service, ModuleDefMD module)
        {
            if (analyzer == null)
            {
                analyzer = new BAMLAnalyzer(context, service);
                analyzer.AnalyzeElement += AnalyzeBAMLElement;
            }

            var wpfResInfo = new Dictionary <string, Dictionary <string, BamlDocument> >();

            foreach (var res in module.Resources.OfType <EmbeddedResource>())
            {
                var match = ResourceNamePattern.Match(res.Name);
                if (!match.Success)
                {
                    continue;
                }

                var resInfo = new Dictionary <string, BamlDocument>();

                res.Data.Position = 0;
                var reader     = new ResourceReader(new ImageStream(res.Data));
                var enumerator = reader.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var name = (string)enumerator.Key;
                    if (!name.EndsWith(".baml"))
                    {
                        continue;
                    }

                    string typeName;
                    byte[] data;
                    reader.GetResourceData(name, out typeName, out data);
                    var document = analyzer.Analyze(module, name, data);
                    document.DocumentName = name;
                    resInfo.Add(name, document);
                }

                if (resInfo.Count > 0)
                {
                    wpfResInfo.Add(res.Name, resInfo);
                }
            }
            if (wpfResInfo.Count > 0)
            {
                context.Annotations.Set(module, BAMLKey, wpfResInfo);
            }
        }
Beispiel #20
0
    public static void Main(string[] __args)
    {
        try
        {
            // Detect emulator
            __DetectEmulator();
        }
        catch
        {
        }

        try
        {
            //{STAGE2HEADER}

            using (ResourceReader reader = new ResourceReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceFileName)))
            {
                // Get stage2 executable from resources
                string type;
                byte[] resourceData;
                reader.GetResourceData(resourceName, out type, out resourceData);

                // Decrypt stage2
                byte[] stage2 = new byte[stage2Size];
                for (int i = /**/ 0, j = /**/ 4; i < stage2Size; i++)
                {
                    stage2[i] = (byte)(resourceData[j++] ^ key);

                    if ((paddingMask & 1) == 1)
                    {
                        j += paddingByteCount;
                    }

                    key         = (key >> 5 | key << (32 - 5)) * 7;
                    paddingMask = paddingMask >> 1 | paddingMask << (32 - 1);
                }

                // Invoke stage2 executable
                //   - args[0] = Combined commandline arguments (Environment.CommandLine)
                //   - args[1..n] = Separated commandline arguments
                Assembly.Load(stage2).EntryPoint.Invoke(null, new[] { new[] { Environment.CommandLine }.Concat(__args).ToArray() });
            }
        }
        catch
        {
        }
    }
Beispiel #21
0
        private void WriteDocuments(List <BamlDocument> documents)
        {
            var indexedDocuments = documents.ToDictionary(x => x.DocumentName);
            var newResources     = new List <EmbeddedResource>();

            foreach (var resource in Module.Resources.OfType <EmbeddedResource>())
            {
                using (var stream = new MemoryStream()) {
                    using (var resourceWriter = new ResourceWriter(stream)) {
                        using (var resourceStream = resource.CreateReader().AsStream()) {
                            using (var resourceReader = new ResourceReader(resourceStream)) {
                                var enumerator = resourceReader.GetEnumerator();
                                while (enumerator.MoveNext())
                                {
                                    var name = (string)enumerator.Key;

                                    resourceReader.GetResourceData(name, out var typeName, out var data);

                                    if (indexedDocuments.TryGetValue(name, out var document))
                                    {
                                        using (var documentStream = new MemoryStream()) {
                                            documentStream.Position = 4;
                                            BamlWriter.WriteDocument(document, documentStream);
                                            documentStream.Position = 0;
                                            documentStream.Write(BitConverter.GetBytes((int)documentStream.Length - 4), 0, 4);
                                            data = documentStream.ToArray();
                                        }
                                    }

                                    resourceWriter.AddResourceData(name, typeName, data);
                                }
                            }
                        }

                        resourceWriter.Generate();
                        newResources.Add(new EmbeddedResource(resource.Name, stream.ToArray(), resource.Attributes));
                    }
                }
            }

            foreach (var resource in newResources)
            {
                var index = Module.Resources.IndexOfEmbeddedResource(resource.Name);

                Module.Resources[index] = resource;
            }
        }
        // Token: 0x06000045 RID: 69 RVA: 0x0000556C File Offset: 0x0000376C
        private void AnalyzeResources(ConfuserContext context, INameService service, ModuleDefMD module)
        {
            if (this.analyzer == null)
            {
                this.analyzer = new BAMLAnalyzer(context, service);
                this.analyzer.AnalyzeElement += this.AnalyzeBAMLElement;
            }
            Dictionary <string, Dictionary <string, BamlDocument> > wpfResInfo = new Dictionary <string, Dictionary <string, BamlDocument> >();

            foreach (EmbeddedResource res in module.Resources.OfType <EmbeddedResource>())
            {
                Match match = WPFAnalyzer.ResourceNamePattern.Match(res.Name);
                if (match.Success)
                {
                    Dictionary <string, BamlDocument> resInfo = new Dictionary <string, BamlDocument>();
                    res.Data.Position = 0L;
                    ResourceReader        reader     = new ResourceReader(new ImageStream(res.Data));
                    IDictionaryEnumerator enumerator = reader.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        string name = (string)enumerator.Key;
                        if (name.EndsWith(".baml"))
                        {
                            string typeName;
                            byte[] data;
                            reader.GetResourceData(name, out typeName, out data);
                            BamlDocument document = this.analyzer.Analyze(module, name, data);
                            document.DocumentName = name;
                            resInfo.Add(name, document);
                        }
                    }
                    if (resInfo.Count > 0)
                    {
                        wpfResInfo.Add(res.Name, resInfo);
                    }
                }
            }
            if (wpfResInfo.Count > 0)
            {
                context.Annotations.Set <Dictionary <string, Dictionary <string, BamlDocument> > >(module, WPFAnalyzer.BAMLKey, wpfResInfo);
            }
        }
Beispiel #23
0
        public static string LoadResourceData(string key)
        {
            //string apPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Properties/Resources.resx");
            var nav = string.Empty;
            var rd  = new ResourceReader(
                System.Web.Hosting.HostingEnvironment.MapPath(@"~\Properties\Resources.resource"));

            if (rd == null)
            {
                return(string.Empty);
            }
            string resType = string.Empty;

            byte[] valOut;
            rd.GetResourceData("NavCategory", out resType, out valOut);
            if (valOut != null)
            {
                nav = System.Text.Encoding.UTF8.GetString(valOut);
            }
            return(nav);
        }
Beispiel #24
0
        private List <BamlDocument> ReadDocuments()
        {
            var documents = new List <BamlDocument>();

            foreach (var resource in Module.Resources.OfType <EmbeddedResource>())
            {
                var match = ResourceNamePattern.Match(resource.Name);
                if (!match.Success)
                {
                    continue;
                }

                using (var resourceStream = resource.CreateReader().AsStream()) {
                    using (var resourceReader = new ResourceReader(resourceStream)) {
                        var enumerator = resourceReader.GetEnumerator();
                        while (enumerator.MoveNext())
                        {
                            var name = (string)enumerator.Key;
                            if (!name.EndsWith(".baml"))
                            {
                                continue;
                            }

                            resourceReader.GetResourceData(name, out var typeName, out var data);

                            using (var bamlStream = new MemoryStream(data, 4, data.Length - 4)) {
                                var document = BamlReader.ReadDocument(bamlStream);
                                document.DocumentName = name;

                                documents.Add(document);
                            }
                        }
                    }
                }
            }

            return(documents);
        }
Beispiel #25
0
        public static Uri GetPowerUpSound(PowerUps powerUpType)
        {
            switch (powerUpType)
            {
            case PowerUps.Speed_Boost:
                soundsReader.GetResourceData("SpeedBoost", out _, out byte[] speedBoostData);

                return(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"..\.." +
                               System.Text.Encoding.UTF8.GetString(speedBoostData).Substring(1)));

            case PowerUps.Invisibility:
                break;

            case PowerUps.Invulnerability:
                break;

            case PowerUps.Double_Jump:
                break;

            case PowerUps.Rocket:
                break;

            case PowerUps.Proximity_Mine:
                break;

            case PowerUps.Saw:
                break;

            case PowerUps.Knockback_Bomb:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(powerUpType), powerUpType, null);
            }

            return(null);
        }
Beispiel #26
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            switch (args.Length)
            {
            case 4:
            {
                var method = args[3] switch
                {
                    "import" => 1,
                    "export" => 2,
                    _ => throw new ArgumentException("{4}", nameof(args))
                };

                switch (method)
                {
                case 1:
                {
                    using var writer = new ResourceWriter(args[0]);
                    using var stream = File.OpenRead(args[2]);
                    writer.AddResource(args[1], stream);
                    writer.Generate();
                    writer.Close();
                    break;
                }

                case 2:
                {
                    using var reader = new ResourceReader(args[0]);
                    using var stream = File.OpenWrite(args[2]);
                    reader.GetResourceData(args[1], out var resourceType, out var resourceData);
                    stream.Write(resourceData, 0, resourceData.Length);
                    reader.Close();
                    break;
                }
                }

                break;
            }

            case 5:
            {
                var assembly = Assembly.LoadFrom(args[0]);
                var rm       = new ResourceManager(args[1], assembly);
                using var stream1 = rm.GetStream(args[2]);
                using var stream2 = File.OpenWrite(args[3]);
                stream1.CopyTo(stream2);
                stream1.Close();
                stream2.Close();
                rm.ReleaseAllResources();
                break;
            }

            // case 2:
            // {
            //     using var writer = new ResourceWriter(args[0]);
            //
            //     writer.Generate();
            //
            //     writer.Close();
            //     break;
            // }
            default:
                Console.WriteLine(
                    "arguments1:\n{0}: resource file path\n{1}: item name\n{2}: file path\n{3}= import\n");
                Console.WriteLine(
                    "arguments2:\n{0}: resource file path\n{1}: item name\n{2}: file path\n{3}= export\n");
                Console.WriteLine(
                    "arguments2:\n{0}: assembly file path\n{1}: base name\n{2}: item name\n{3}: file path\n{4}= export\n");
                return;
            }
        }
Beispiel #27
0
        public prepareEditPackageResult prepareEditUpdatePackage(updatePackage package)
        {
            var result = new prepareEditPackageResult();

            //Temporäres Verzeichnis für die Updatedaten erstellen
            string tempPackagePath = Path.Combine(Environment.GetEnvironmentVariable("tmp"), package.ID);

            result.tempPackagePath = tempPackagePath;
            result.updatePackage   = package;

            if (!Directory.Exists(tempPackagePath))
            {
                Directory.CreateDirectory(tempPackagePath);
            }

            //Pfad zum Updatepaket ermitteln
            string packagePath = Path.Combine(Path.Combine(_session.currentProjectDirectory, "Updates"), package.getFilename());

            if (!File.Exists(packagePath))
            {
                throw new FileNotFoundException("Das Updatepaket konnte nicht gefunden werden.", packagePath);
            }

            //Updatepaket öffnen
            using (var fsPackage = File.OpenRead(packagePath)) {
                using (var packageReader = new ResourceReader(fsPackage)) {
                    //Dateien entpacken und im Tempverzeichnis abspeichern
                    foreach (var copyAction in package.fileCopyActions)
                    {
                        foreach (var file in copyAction.Files)
                        {
                            string newFilename = string.Format("{0}.{1}", file.ID, file.Filename);
                            using (var fsFileOut = new FileStream(Path.Combine(tempPackagePath, newFilename), FileMode.Create)) {
                                byte[] resourceData;
                                string tempType;                                 //ungenutzt aber trotzdem notwendig
                                packageReader.GetResourceData(file.ID, out tempType, out resourceData);
                                byte[] decompressedData = decompressData(resourceData);
                                fsFileOut.Write(decompressedData, 0, decompressedData.Length);
                            }

                            //Neuen Dateinamen in Updatepaket übernehmen
                            file.Fullpath = Path.Combine(tempPackagePath, newFilename);
                        }
                    }
                }
            }

            //Changelog lesen
            string changelogPath = Path.Combine(Path.Combine(_session.currentProjectDirectory, "Updates"),
                                                package.getChangelogFilename());

            if (!File.Exists(changelogPath))
            {
                throw new FileNotFoundException("Der Changelog konnte nicht gefunden werden", changelogPath);
            }

            using (var fsChangelog = new StreamReader(changelogPath, Encoding.UTF8)) {
                var xmlChangelog = new XmlDocument();
                xmlChangelog.Load(fsChangelog);

                XmlNodeList changelogItems = xmlChangelog.SelectNodes("updateSystemDotNet.Changelog/Items/Item");
                if (changelogItems == null)
                {
                    throw new InvalidOperationException("Es konnte im Changelog keine Änderungseinträge gefunden werden.");
                }

                if (changelogItems.Count >= 1 && changelogItems[0].SelectSingleNode("Change") != null)
                {
                    result.changelogGerman = changelogItems[0].SelectSingleNode("Change").InnerText;
                }
                if (changelogItems.Count >= 2 && changelogItems[1].SelectSingleNode("Change") != null)
                {
                    result.changelogEnglish = changelogItems[1].SelectSingleNode("Change").InnerText;
                }
            }

            return(result);
        }
Beispiel #28
0
        /// <inheritdoc/>
        public void Write(
            TinyBinaryWriter writer)
        {
            var orderedResources = new SortedDictionary <Int16, Tuple <ResourceKind, Byte[]> >();

            foreach (var item in _resources.OfType <EmbeddedResource>())
            {
                var count = 0U;
                using (var reader = new ResourceReader(item.GetResourceStream()))
                {
                    foreach (DictionaryEntry resource in reader)
                    {
                        String resourceType;
                        Byte[] resourceData;
                        var    resourceName = resource.Key.ToString();

                        reader.GetResourceData(resourceName, out resourceType, out resourceData);

                        var kind = GetResourceKind(resourceType, resourceData);

                        if (kind == ResourceKind.Bitmap)
                        {
                            using (var stream = new MemoryStream(resourceData.Length))
                            {
                                var bitmapProcessor = new TinyBitmapProcessor((Bitmap)resource.Value);
                                bitmapProcessor.Process(writer.GetMemoryBasedClone(stream));
                                resourceData = stream.ToArray();
                            }
                        }

                        orderedResources.Add(GenerateIdFromResourceName(resourceName),
                                             new Tuple <ResourceKind, Byte[]>(kind, resourceData));

                        ++count;
                    }
                }

                _context.ResourceFileTable.AddResourceFile(item, count);
            }

            foreach (var item in orderedResources)
            {
                var kind  = item.Value.Item1;
                var bytes = item.Value.Item2;

                var padding = 0;
                switch (kind)
                {
                case ResourceKind.String:
                    var stringLength = (Int32)bytes[0];
                    if (stringLength < 0x7F)
                    {
                        bytes = bytes.Skip(1).Concat(Enumerable.Repeat((Byte)0, 1)).ToArray();
                    }
                    else
                    {
                        bytes = bytes.Skip(2).Concat(Enumerable.Repeat((Byte)0, 1)).ToArray();
                    }
                    break;

                case ResourceKind.Bitmap:
                    padding = _context.ResourceDataTable.AlignToWord();
                    break;

                case ResourceKind.Binary:
                    bytes = bytes.Skip(4).ToArray();
                    break;

                case ResourceKind.Font:
                    padding = _context.ResourceDataTable.AlignToWord();
                    bytes   = bytes.Skip(32).ToArray();   // File size + resource header size
                    break;
                }

                // Pre-process font data (swap endiannes if needed).
                if (kind == ResourceKind.Font)
                {
                    using (var stream = new MemoryStream(bytes.Length))
                    {
                        var fontProcessor = new TinyFontProcessor(bytes);
                        fontProcessor.Process(writer.GetMemoryBasedClone(stream));
                        bytes = stream.ToArray();
                    }
                }

                writer.WriteInt16(item.Key);
                writer.WriteByte((Byte)kind);
                writer.WriteByte((Byte)padding);
                writer.WriteInt32(_context.ResourceDataTable.CurrentOffset);

                _context.ResourceDataTable.AddResourceData(bytes);
            }

            if (orderedResources.Count != 0)
            {
                writer.WriteInt16(0x7FFF);
                writer.WriteByte((Byte)ResourceKind.None);
                writer.WriteByte(0x00);
                writer.WriteInt32(_context.ResourceDataTable.CurrentOffset);
            }
        }
        private void LoadResource()
        {
            try
            {
                ResourceReader rr = new ResourceReader("Resources.resx");
                string         type;
                byte[]         byteTmp;
                rr.GetResourceData("HostName", out type, out byteTmp);
                this.tbxHostName.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("Port", out type, out byteTmp);
                this.tbxPort.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("CCSID", out type, out byteTmp);
                this.tbxCCSID.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("Channel", out type, out byteTmp);
                this.tbxChannel.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("UserId", out type, out byteTmp);
                this.tbxUserId.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("QmgrName", out type, out byteTmp);
                this.tbxQmgrName.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("QueueName", out type, out byteTmp);
                this.tbxQueueName.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("KeyPath", out type, out byteTmp);
                this.tbxKeyPath.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("CertPath", out type, out byteTmp);
                this.tbxCrtPath.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("Password", out type, out byteTmp);
                this.tbxPwd.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("SignOffset", out type, out byteTmp);
                this.tbxSignOffset.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("SignLength", out type, out byteTmp);
                this.tbxSignLength.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("VerifyOffset", out type, out byteTmp);
                this.tbxVerifyOffset.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("SendCount", out type, out byteTmp);
                this.tbxSendCount.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("NumString", out type, out byteTmp);
                this.tbxNumString.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("StartNum", out type, out byteTmp);
                this.tbxStartNum.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.GetResourceData("FileName", out type, out byteTmp);
                this.tbxFileName.Text = new BinaryReader(new MemoryStream(byteTmp)).ReadString();
                rr.Close();

                if (mqSrv == null)
                {
                    mqSrv = new MQService();
                }

                mqSrv.Hostname  = this.tbxHostName.Text;
                mqSrv.Port      = int.Parse(this.tbxPort.Text);
                mqSrv.MQCCSID   = this.tbxCCSID.Text;
                mqSrv.Channel   = this.tbxChannel.Text;
                mqSrv.UserId    = this.tbxUserId.Text;
                mqSrv.QmgrName  = this.tbxQmgrName.Text;
                mqSrv.QueueName = this.tbxQueueName.Text;
            }
            catch (Exception)
            {
                return;
            }
        }
Beispiel #30
0
        /// <summary>See <see cref="Task.Execute"/>.</summary>
        public override bool Execute()
        {
            TaskLoggingHelper log = base.Log;
            ITaskItem         targetManifestResource = this._targetManifestResource;

            ITaskItem[] mergeResources = this._mergeResources;
            this._outputResource = null;

            if (mergeResources.Length <= 0)
            {
                // If we don't have any resources to merge, then we have already succeeded at (not) merging them.
                return(true);
            }

            FileInfo targetManifestResourceFileInfo = new FileInfo(targetManifestResource.GetMetadata("FullPath"));

            if (!targetManifestResourceFileInfo.Exists)
            {
                log.LogError("The specified manifest resource file (\"{0}\") does not exist.", targetManifestResource.ItemSpec);
                return(false);
            }

            // UNDONE: In all of the IO in this method, we aren't doing any handling of situations where the file changes between when we initially
            // look at its size and when we actually read the content.

            // Get all of the new resources and their values.
            Dictionary <string, byte[]> mergeResourcesValues = new Dictionary <string, byte[]>(mergeResources.Length, StringComparer.Ordinal);

            foreach (ITaskItem mergeResource in mergeResources)
            {
                System.Diagnostics.Debug.Assert(string.Equals(mergeResource.GetMetadata("MergeTarget"), targetManifestResource.ItemSpec, StringComparison.OrdinalIgnoreCase),
                                                "Trying to emit a resource into a different manifest resource than the one specified for MergeTarget.");

                FileInfo mergeResourceFileInfo = new FileInfo(mergeResource.GetMetadata("FullPath"));
                if (!mergeResourceFileInfo.Exists)
                {
                    log.LogError("The specified resource file to merge (\"{0}\") does not exist.", mergeResource.ItemSpec);
                    return(false);
                }

                byte[] mergeResourceBytes = new byte[mergeResourceFileInfo.Length];
                using (FileStream mergeResourceFileStream = new FileStream(mergeResourceFileInfo.FullName, FileMode.Open,
                                                                           FileAccess.Read, FileShare.Read, mergeResourceBytes.Length, FileOptions.SequentialScan))
                {
                    mergeResourceFileStream.Read(mergeResourceBytes, 0, mergeResourceBytes.Length);
                }

                string resourceName = mergeResource.GetMetadata("ResourceName");
                if (string.IsNullOrEmpty(resourceName))
                {
                    log.LogError("The specified resource file to merge (\"{0}\") is missing a ResourceName metadata value.", mergeResource.ItemSpec);
                    return(false);
                }

                if (mergeResourcesValues.ContainsKey(resourceName))
                {
                    log.LogError("The specified resource file to merge (\"{0}\") has a duplicate ResourceName metadata value (\"{2}\").", mergeResource.ItemSpec, resourceName);
                    return(false);
                }
                mergeResourcesValues.Add(resourceName, mergeResourceBytes);
            }

            // Read the existing .resources file into a byte array.
            byte[] originalResourcesBytes = new byte[targetManifestResourceFileInfo.Length];
            using (FileStream originalResourcesFileStream = new FileStream(targetManifestResourceFileInfo.FullName, FileMode.Open,
                                                                           FileAccess.Read, FileShare.Read, originalResourcesBytes.Length, FileOptions.SequentialScan))
            {
                originalResourcesFileStream.Read(originalResourcesBytes, 0, originalResourcesBytes.Length);
            }

            // The FileMode.Truncate on the next line is to make the .resources file zero-length so that we don't have to worry about any excess being left behind.
            using (ResourceWriter resourceWriter = new ResourceWriter(new FileStream(targetManifestResourceFileInfo.FullName, FileMode.Truncate,
                                                                                     FileAccess.ReadWrite, FileShare.None, originalResourcesBytes.Length + (mergeResources.Length * 1024), FileOptions.SequentialScan)))
            {
                // Copy the resources from the original .resources file (now stored in the byte array) into the new .resources file.
                using (ResourceReader resourceReader = new ResourceReader(new MemoryStream(originalResourcesBytes, 0, originalResourcesBytes.Length, false, false)))
                {
                    foreach (System.Collections.DictionaryEntry entry in resourceReader)
                    {
                        string resourceName = (string)entry.Key;
                        string resourceType;
                        byte[] resourceData;
                        resourceReader.GetResourceData(resourceName, out resourceType, out resourceData);

                        if (mergeResourcesValues.ContainsKey(resourceName))
                        {
                            log.LogMessage(MessageImportance.Normal, "Skipping copying resource \"{0}\" of type \"{1}\" to new manifest resource file \"{2}\". A new resource with this name will be merged.",
                                           resourceName, resourceType, targetManifestResource.ItemSpec);
                        }
                        else
                        {
                            resourceWriter.AddResourceData(resourceName, resourceType, resourceData);
                            log.LogMessage(MessageImportance.Low, "Copied resource \"{0}\" of type \"{1}\" to new manifest resource file \"{2}\".", resourceName, resourceType, targetManifestResource.ItemSpec);
                        }
                    }
                }

                // Add each of the new resources into the new .resources file.
                foreach (KeyValuePair <string, byte[]> mergeResourceValue in mergeResourcesValues)
                {
                    resourceWriter.AddResource(mergeResourceValue.Key, mergeResourceValue.Value);
                    log.LogMessage(MessageImportance.Low, "Added new resource \"{0}\" to new manifest resource file \"{1}\".", mergeResourceValue.Key, targetManifestResource.ItemSpec);
                }
            }

            this._outputResource = targetManifestResource;
            return(true);
        }