상속: BaseModel
예제 #1
0
        private static void LoadHistoricEvent(string filename)
        {
            var doc = new XmlDocument();
            doc.Load(filename);
            XmlElement root = doc.DocumentElement;

            if (root != null)
            {
                string name = root.Attributes["name"].Value;
                string text = root.Attributes["text"].Value;
                DateTime eventDate = Convert.ToDateTime(root.Attributes["date"].Value, new CultureInfo("en-US", false));

                var historicEvent = new HistoricEvent(name, text, eventDate);

                XmlNodeList influencesList = root.SelectNodes("influences/influence");

                if (influencesList != null)
                    foreach (XmlElement influenceElement in influencesList)
                    {
                        var type =
                            (HistoricEventInfluence.InfluenceType)
                            Enum.Parse(
                                typeof (HistoricEventInfluence.InfluenceType),
                                influenceElement.Attributes["type"].Value);
                        double value = Convert.ToDouble(
                            influenceElement.Attributes["value"].Value,
                            CultureInfo.GetCultureInfo("en-US").NumberFormat);
                        DateTime endDate = Convert.ToDateTime(
                            influenceElement.Attributes["enddate"].Value,
                            new CultureInfo("en-US", false));

                        historicEvent.AddInfluence(new HistoricEventInfluence(type, value, endDate));
                    }

                HistoricEvents.AddHistoricEvent(historicEvent);
            }
        }
 public static void AddHistoricEvent(HistoricEvent e)
 {
     Events.Add(e);
 }