Example #1
0
        internal static PinyinUnit Deserialize(BinaryReader binaryReader)
        {
            PinyinUnit unit = new PinyinUnit();

            byte[] bytes = binaryReader.ReadBytes(7);
            unit.Pinyin = Encoding.ASCII.GetString(bytes, 0, 7);
            char[] trimChars = new char[1];
            unit.Pinyin = unit.Pinyin.TrimEnd(trimChars);
            return(unit);
        }
Example #2
0
        internal static PinyinUnit Deserialize(BinaryReader binaryReader)
        {
            PinyinUnit pinyinUnit = new PinyinUnit();

            byte[] bytes = binaryReader.ReadBytes(7);
            pinyinUnit.Pinyin = Encoding.ASCII.GetString(bytes, 0, 7);
            char[] chArray = new char[1];
            pinyinUnit.Pinyin = pinyinUnit.Pinyin.TrimEnd(chArray);
            return(pinyinUnit);
        }
Example #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);
        }
Example #4
0
        public ChineseChar(char ch)
        {
            if (!IsValidChar(ch))
            {
                throw new NotSupportedException(AssemblyResource.CHARACTER_NOT_SUPPORTED);
            }
            this.chineseCharacter = ch;
            CharUnit charUnit = charDictionary.GetCharUnit(ch);

            this.strokeNumber = charUnit.StrokeNumber;
            this.pinyinCount  = charUnit.PinyinCount;
            this.isPolyphone  = charUnit.PinyinCount > 1;
            for (int i = 0; i < this.pinyinCount; i++)
            {
                PinyinUnit pinYinUnitByIndex = pinyinDictionary.GetPinYinUnitByIndex(charUnit.PinyinIndexList[i]);
                this.pinyinList[i] = pinYinUnitByIndex.Pinyin;
            }
        }
Example #5
0
        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);
        }
Example #6
0
 internal bool Match(PinyinUnit pinyinUnit)
 {
     return(string.Compare(pinyinUnit.Pinyin, ExpectedPinyin, true, System.Globalization.CultureInfo.CurrentCulture) == 0);
 }
 internal bool Match(PinyinUnit pinyinUnit)
 {
     return(string.Compare(pinyinUnit.Pinyin, this.ExpectedPinyin, true, CultureInfo.CurrentCulture) == 0);
 }