Пример #1
0
        static ChineseChar()
        {
            string str;

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

            using (Stream stream = executingAssembly.GetManifestResourceStream("iPortal.Common.Converter.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("iPortal.Common.Converter.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("iPortal.Common.Converter.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("iPortal.Common.Converter.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);
                    }
                }
            }
        }
Пример #2
0
        internal static HomophoneDictionary Deserialize(BinaryReader binaryReader)
        {
            HomophoneDictionary dictionary = new HomophoneDictionary();

            binaryReader.ReadInt32();
            dictionary.Length = binaryReader.ReadInt32();
            dictionary.Count  = binaryReader.ReadInt16();
            dictionary.Offset = binaryReader.ReadInt16();
            binaryReader.ReadBytes(8);
            dictionary.HomophoneUnitTable = new List <HomophoneUnit>();
            for (int i = 0; i < dictionary.Count; i++)
            {
                dictionary.HomophoneUnitTable.Add(HomophoneUnit.Deserialize(binaryReader));
            }
            binaryReader.ReadInt16();
            return(dictionary);
        }