コード例 #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);
                    }
                }
            }
        }
コード例 #2
0
ファイル: ChineseChar.cs プロジェクト: eimslab/Shove.Net.Fx2
        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);
                    }
                }
            }
        }
コード例 #3
0
        internal static PinyinDictionary Deserialize(BinaryReader binaryReader)
        {
            PinyinDictionary dictionary = new PinyinDictionary();

            binaryReader.ReadInt32();
            dictionary.Length = binaryReader.ReadInt16();
            dictionary.Count  = binaryReader.ReadInt16();
            dictionary.Offset = binaryReader.ReadInt16();
            binaryReader.ReadBytes(8);
            dictionary.PinyinUnitTable = new List <PinyinUnit>();
            for (int i = 0; i < dictionary.Count; i++)
            {
                dictionary.PinyinUnitTable.Add(PinyinUnit.Deserialize(binaryReader));
            }
            binaryReader.ReadInt16();
            return(dictionary);
        }
コード例 #4
0
ファイル: PinyinDictionary.cs プロジェクト: TkYu/MSIFPCore
        internal static PinyinDictionary Deserialize(BinaryReader binaryReader)
        {
            PinyinDictionary pinyinDictionary = new PinyinDictionary();

            binaryReader.ReadInt32();
            pinyinDictionary.Length = binaryReader.ReadInt16();
            pinyinDictionary.Count  = binaryReader.ReadInt16();
            pinyinDictionary.Offset = binaryReader.ReadInt16();
            binaryReader.ReadBytes(8);
            pinyinDictionary.PinyinUnitTable = new List <PinyinUnit>();
            for (int index = 0; index < (int)pinyinDictionary.Count; ++index)
            {
                pinyinDictionary.PinyinUnitTable.Add(PinyinUnit.Deserialize(binaryReader));
            }
            int num = (int)binaryReader.ReadInt16();

            return(pinyinDictionary);
        }
コード例 #5
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);
        }
コード例 #6
0
 internal HomophoneUnit GetHomophoneUnit(PinyinDictionary pinyinDictionary, string pinyin)
 {
     return(this.GetHomophoneUnit(pinyinDictionary.GetPinYinUnitIndex(pinyin)));
 }