Exemplo n.º 1
0
        public static House fromXMLStream(DataInputStream @is, string houseName, int houseId)
        {
            int length1 = @is.available();

            sbyte[] b       = new sbyte[length1];
            char[]  chArray = new char[length1];
            @is.readFully(b);
            for (int index = 0; index < length1; ++index)
            {
                chArray[index] = (char)b[index];
            }
            string str1       = new string(chArray);
            string str2       = "<room ";
            string str3       = "<door ";
            string str4       = "<window ";
            string str5       = "<object ";
            House  house      = new House(houseName, houseId);
            int    startIndex = 0;

            do
            {
                int    length2 = str1.IndexOf('\n', startIndex);
                string str6    = str1.Substring(startIndex, length2);
                if (str6.IndexOf(str2) != -1)
                {
                    house.addRoom(Room.fromXMLString(str6));
                }
                else if (str6.IndexOf(str3) != -1)
                {
                    house.addDoor(Door.fromXMLString(str6));
                }
                else if (str6.IndexOf(str4) != -1)
                {
                    house.addWindow(Window.fromXMLString(str6));
                }
                else if (str6.IndexOf(str5) != -1)
                {
                    house.addHouseObject(HouseObject.fromXMLString(str6));
                }
                startIndex = length2 + 1;
            }while (startIndex < str1.Length);
            return(house);
        }