예제 #1
0
    // Fills the object list with Tree nodes that are connected.
    public void FillFromFile(string filename)
    {
        var lines = File.ReadLines(filename);

        foreach (var line in lines)
        {
            string parent = line.Substring(0, 3);
            string child  = line.Substring(4, 3);

            ObjectNode parentNode = GetObject(parent, true);
            ObjectNode childNode  = GetObject(child, true);

            parentNode.AddChild(childNode);
            childNode.SetParent(parentNode);
        }

        InitRoot();  // find the root by traversing upwards through the parents.
    }