Beispiel #1
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);
                    }
                }
            }
        }
Beispiel #2
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);
                    }
                }
            }
        }
Beispiel #3
0
        internal static HomophoneDictionary Deserialize(BinaryReader binaryReader)
        {
            HomophoneDictionary homophoneDictionary = new HomophoneDictionary();

            binaryReader.ReadInt32();
            homophoneDictionary.Length = binaryReader.ReadInt32();
            homophoneDictionary.Count  = binaryReader.ReadInt16();
            homophoneDictionary.Offset = binaryReader.ReadInt16();
            binaryReader.ReadBytes(8);
            homophoneDictionary.HomophoneUnitTable = new List <HomophoneUnit>();
            for (int i = 0; i < (int)homophoneDictionary.Count; i++)
            {
                homophoneDictionary.HomophoneUnitTable.Add(HomophoneUnit.Deserialize(binaryReader));
            }
            binaryReader.ReadInt16();
            return(homophoneDictionary);
        }
Beispiel #4
0
        static ChineseChar()
        {
            using (var stream = new MemoryStream(Properties.Resources.CharDictionary))
                using (var reader = new BinaryReader(stream))
                    charDictionary = CharDictionary.Deserialize(reader);

            using (var stream = new MemoryStream(Properties.Resources.HomophoneDictionary))
                using (var reader = new BinaryReader(stream))
                    homophoneDictionary = HomophoneDictionary.Deserialize(reader);

            using (var stream = new MemoryStream(Properties.Resources.PinyinDictionary))
                using (var reader = new BinaryReader(stream))
                    pinyinDictionary = PinyinDictionary.Deserialize(reader);

            using (var stream = new MemoryStream(Properties.Resources.StrokeDictionary))
                using (var reader = new BinaryReader(stream))
                    strokeDictionary = StrokeDictionary.Deserialize(reader);
        }