Esempio n. 1
0
        public bool AddLocation(string locationToAdd, string parentLocation)
        {
            lock (allLocations)
            {
                if (allLocations.ContainsKey(locationToAdd))
                {
                    return false;
                }
                else if (!allLocations.ContainsKey(parentLocation))
                {
                    return false;
                }
                else
                {
                    Location location = new Location(locationToAdd);

                    location.SetParent(allLocations[parentLocation]);
                    allLocations[parentLocation].AddChildLocation(location);

                    allLocations.Add(locationToAdd, location);

                    WriteLocationTree();

                    return true;
                }
            }
        }
Esempio n. 2
0
        private void ReadLocationSubTree(XmlElement xmlParent, Location parent)
        {
            foreach (XmlElement xmlChild in xmlParent.ChildNodes)
            {
                if (!xmlChild.Name.Equals("Location"))
                    throw new Exception("Location file has node " + xmlChild.Name);

                string name = xmlChild.GetAttribute("Name");
                int id = ++nextLocId;

                Location child = new Location(id, name);

                allLocations.Add(name, child);

                child.SetParent(parent);
                parent.AddChildLocation(child);

                //read the rest of the tree
                ReadLocationSubTree(xmlChild, child);
             }
        }