public static City MakeCity(XmlDocument city, string name) { var properties = PropertyHandler.GetProperties(); if (properties.ContainsKey("availableCars")) { PropertyHandler.ResetProperties(); } var cityObject = new City(name); var root = city.DocumentElement; if (root == null) { throw new XmlException("Missing root node"); } //selecting and adding roads to List var roads = city.SelectSingleNode("//City/Roads"); if (roads == null) { throw new XmlException("Missing roads in city."); } foreach (var road in roads.ChildNodes) { cityObject.Roads.Add(ParseRoad((XmlNode)road)); } //selecting and adding buildings to List var buildings = city.SelectSingleNode("//City/Buildings"); if (buildings == null) { throw new XmlException("Missing buildings in city."); } foreach (var building in buildings.ChildNodes) { cityObject.Buildings.Add(ParseBuilding((XmlNode)building)); } //selecting and adding intersections to list var intersections = city.SelectSingleNode("//City/Intersections"); if (intersections == null) { throw new XmlException("Missing intersections in city."); } foreach (var intersection in intersections.ChildNodes) { cityObject.Intersections.Add(ParseIntersection((XmlNode)intersection)); } try { NodeNetwork.GenerateNetwork(cityObject.Roads, cityObject.Intersections); } catch (Exception) { App.Console?.Print("Unable to load road network!", Colors.Red); } return(cityObject); }
public CityBuilder() { PropertyHandler.ResetProperties(); City = new City("Test City"); }
public CustomerGroupBuilder(Vector startLocation, Vector destination) { PropertyHandler.ResetProperties(); CustomerGroup = new CustomerGroup(random.Next(1, (int)Math.Round(3 / 2.0 * 3.0)), new Building(startLocation, 10), new Building(destination, 10)); }