Exemplo n.º 1
0
    public static void Deserialize(Puzzle emptyPuzzle, TextReader reader)
    {
        SerializationTool tool = new SerializationTool(emptyPuzzle);

        emptyPuzzle.name = reader.ReadLine();

        while (reader.Peek() != -1)
        {
            string             line = reader.ReadLine();
            PuzzleSerializable obj  = tool.DeserializePartly(line);
            if (obj is PuzzleNode)
            {
                emptyPuzzle.AddNode(obj as PuzzleNode);
            }
            else if (obj is PuzzleEdge)
            {
                emptyPuzzle.AddEdge(obj as PuzzleEdge);
            }
            else if (obj is PuzzleElement)
            {
                emptyPuzzle.AddElement(obj as PuzzleElement);
            }
            else if (obj is PuzzleItem)
            {
                emptyPuzzle.AddItem(obj as PuzzleItem);
            }
        }

        tool.Final();
    }