Exemplo n.º 1
0
        internal static HomophoneUnit Deserialize(BinaryReader binaryReader, StringBuilder sb)
        {
            HomophoneUnit homophoneUnit = new HomophoneUnit()
            {
                Count = binaryReader.ReadInt16()
            };

            sb.Append(string.Format("{0},", homophoneUnit.Count));
            homophoneUnit.HomophoneList = new char[(int)homophoneUnit.Count];
            for (int index = 0; index < (int)homophoneUnit.Count; ++index)
            {
                homophoneUnit.HomophoneList[index] = binaryReader.ReadChar();
                sb.Append(homophoneUnit.HomophoneList[index]).Append(",");
            }
            sb.Append(System.Environment.NewLine);
            return(homophoneUnit);
        }
Exemplo n.º 2
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>();
            StringBuilder sb = new StringBuilder();

            for (int index = 0; index < (int)homophoneDictionary.Count; ++index)
            {
                homophoneDictionary.HomophoneUnitTable.Add(HomophoneUnit.Deserialize(binaryReader, sb));
            }
            int num = (int)binaryReader.ReadInt16();

            File.WriteAllText("homophoneDictionary.txt", sb.ToString(), Encoding.UTF8);
            return(homophoneDictionary);
        }