コード例 #1
0
ファイル: HomophoneUnit.cs プロジェクト: TkYu/MSIFPCore
        internal static HomophoneUnit Deserialize(BinaryReader binaryReader)
        {
            HomophoneUnit homophoneUnit = new HomophoneUnit();

            homophoneUnit.Count         = binaryReader.ReadInt16();
            homophoneUnit.HomophoneList = new char[(int)homophoneUnit.Count];
            for (int index = 0; index < (int)homophoneUnit.Count; ++index)
            {
                homophoneUnit.HomophoneList[index] = binaryReader.ReadChar();
            }
            return(homophoneUnit);
        }
コード例 #2
0
        /// <summary>
        /// 获取给定拼音的所有同音字。
        /// </summary>
        /// <param name="pinyin">指出读音。</param>
        /// <returns>返回具有相同的指定拼音的字符串列表。 如果拼音不是有效值则返回空。 </returns>
        public static char[] GetChars(string pinyin)
        {
            if (pinyin == null)
            {
                throw new ArgumentNullException("pinyin");
            }
            if (!ChineseChar.IsValidPinyin(pinyin))
            {
                return(null);
            }
            HomophoneUnit homophoneUnit = ChineseChar.homophoneDictionary.GetHomophoneUnit(ChineseChar.pinyinDictionary, pinyin);

            return(homophoneUnit.HomophoneList);
        }
コード例 #3
0
        internal static HomophoneUnit Deserialize(BinaryReader binaryReader)
        {
            HomophoneUnit unit;

            unit = new HomophoneUnit {
                Count         = binaryReader.ReadInt16(),
                HomophoneList = null
            };
            unit.HomophoneList = new char[unit.Count];

            for (int i = 0; i < unit.Count; i++)
            {
                unit.HomophoneList[i] = binaryReader.ReadChar();
            }
            return(unit);
        }
コード例 #4
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);
        }