public static void AddAirlineMerger(AirlineMerger merger)
 {
     Mergers.Add(merger);
 }
Exemplo n.º 2
0
        private static void LoadAirlineMergers()
        {
            var doc = new XmlDocument();
            doc.Load(AppSettings.GetDataPath() + "\\addons\\airlines\\mergers\\mergers.xml");
            XmlElement root = doc.DocumentElement;

            XmlNodeList mergersList = root?.SelectNodes("//merger");

            if (mergersList != null)
                foreach (XmlElement element in mergersList)
                {
                    string mergerName = element.Attributes["name"].Value;
                    Airline airline1 = Airlines.GetAirline(element.Attributes["airline1"].Value);
                    Airline airline2 = Airlines.GetAirline(element.Attributes["airline2"].Value);
                    var mergerType =
                        (AirlineMerger.MergerType)
                            Enum.Parse(typeof (AirlineMerger.MergerType), element.Attributes["type"].Value);
                    DateTime mergerDate = DateTime.Parse(element.Attributes["date"].Value, new CultureInfo("en-US", false));

                    var merger = new AirlineMerger(mergerName, airline1, airline2, mergerDate, mergerType);

                    if (element.HasAttribute("newname"))
                    {
                        merger.NewName = element.Attributes["newname"].Value;
                    }

                    AirlineMergers.AddAirlineMerger(merger);
                }
        }
 //removes a merger from the list
 public static void RemoveAirlineMerger(AirlineMerger merger)
 {
     Mergers.Remove(merger);
 }