public override void addChild(CityNode node)
        {
            if (node.GetType() != typeof(PackageNode) && node.GetType() != typeof(ClassNode))
            {
                throw new ArgumentException("Invalid Model Type; Packages only contain Classes and other Packages as children");
            }

            children[node.GetType() == typeof(PackageNode) ? "packages" : "classes"].Add(node);
        }
        public override void addChild(CityNode node)
        {
            if (node.GetType() != typeof(PackageNode))
            {
                throw new ArgumentException("Invalid Model Type; Projects only contain Packages as children ");
            }

            children["packages"].Add(node);
        }
        public override void addChild(CityNode node)
        {
            if (node.GetType() != typeof(MethodNode))
            {
                throw new ArgumentException("Invalid Model Type; Project only have Packages as children");
            }

            children["methods"].Add(node);
        }
Example #4
0
 public CityLayout(CityNode node, Dictionary <ObjectType, GameObject> prefabs)
 {
     Node         = node;
     this.prefabs = prefabs;
 }
Example #5
0
        private void LoadModel(CityNode parent, XmlNode node)
        {
            CityNode       model;
            List <XmlNode> children = new List <XmlNode>();

            switch (node.Name)
            {
            case "project":
            {
                model = new ProjectNode(node.Attributes["name"].Value);
                parent.addChild(model);

                XmlNode packages = node.SelectSingleNode("./packages");
                if (packages != null)
                {
                    children = children.Concat(packages.ChildNodes.Cast <XmlNode>()).ToList();
                }
                break;
            }

            case "package":
            {
                model = new PackageNode(node.SelectSingleNode("./name").InnerText);
                parent.addChild(model);

                XmlNode packages = node.SelectSingleNode("./packages");
                if (packages != null)
                {
                    children = children.Concat(packages.ChildNodes.Cast <XmlNode>()).ToList();
                }

                XmlNode classes = node.SelectSingleNode("./classes");
                if (classes != null)
                {
                    children = children.Concat(classes.ChildNodes.Cast <XmlNode>()).ToList();
                }
                break;
            }

            case "class":
            {
                string name        = node.SelectSingleNode("./name").InnerText;
                int    loc         = int.Parse(node.SelectSingleNode("./loc").InnerText);
                int    noa         = int.Parse(node.SelectSingleNode("./noa").InnerText);
                bool   isAbstract  = node.Attributes["abstract"] != null ? true : false;
                bool   isInterface = node.Attributes["interface"] != null ? true : false;

                model = new ClassNode(name, loc, noa, isAbstract, isInterface);
                parent.addChild(model);

                XmlNode methods = node.SelectSingleNode("./methods");
                if (methods != null)
                {
                    children = children.Concat(methods.ChildNodes.Cast <XmlNode>()).ToList();
                }
            }
            break;

            case "method":
            {
                string name = node.SelectSingleNode("./name").InnerText;
                int    loc  = int.Parse(node.SelectSingleNode("./loc").InnerText);
                int    nop  = int.Parse(node.SelectSingleNode("./nop").InnerText);

                ((ClassNode)parent).IsEnum = node.SelectSingleNode("./enum") != null;
                model = new MethodNode(name, loc, nop);
                parent.addChild(model);

                // leave children empty since methods have no children
            }
            break;

            default:
                throw new System.Xml.XmlException("Invalid Element Type " + node.Name);
            }

            foreach (XmlNode child in children)
            {
                LoadModel(model, child);
            }
        }
 public abstract void addChild(CityNode node);
 public override void addChild(CityNode node)
 {
     throw new NotImplementedException("Methods have no children");
 }