Ejemplo n.º 1
0
        /*! load the unions
         */
        private static void LoadUnions()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(AppSettings.getDataPath() + "\\unions.xml");
            XmlElement root = doc.DocumentElement;

            XmlNodeList unionsList = root.SelectNodes("//union");
            foreach (XmlElement element in unionsList)
            {
                try
                {
                    string section = root.Name;
                    string uid = element.Attributes["uid"].Value;
                    string shortname = element.Attributes["shortname"].Value;
                    string flag = element.Attributes["flag"].Value;

                    XmlElement periodElement = (XmlElement)element.SelectSingleNode("period");
                    DateTime creationDate = Convert.ToDateTime(periodElement.Attributes["creation"].Value, new CultureInfo("en-US", false));
                    DateTime obsoleteDate = Convert.ToDateTime(periodElement.Attributes["obsolete"].Value, new CultureInfo("en-US", false));

                    Union union = new Union(section, uid, shortname, creationDate, obsoleteDate);
                    XmlNodeList membersList = element.SelectNodes("members/member");

                    foreach (XmlElement memberNode in membersList)
                    {
                        Country country = Countries.GetCountry(memberNode.Attributes["country"].Value);
                        DateTime fromDate = Convert.ToDateTime(memberNode.Attributes["memberfrom"].Value, new CultureInfo("en-US", false));
                        DateTime toDate = Convert.ToDateTime(memberNode.Attributes["memberto"].Value, new CultureInfo("en-US", false));

                        if (country == null)
                        {
                            uid = "";
                        }

                        union.addMember(new UnionMember(country, fromDate, toDate));
                    }

                    union.Flag = AppSettings.getDataPath() + "\\graphics\\flags\\" + flag + ".png";
                    Unions.AddUnion(union);

                    if (element.SelectSingleNode("translations") != null)
                        Translator.GetInstance().addTranslation(root.Name, element.Attributes["uid"].Value, element.SelectSingleNode("translations"));
                }
                catch (Exception)
                {
                    throw new Exception("Error on reading unions");
                }
            }
        }
Ejemplo n.º 2
0
 //adds an union to the list
 public static void AddUnion(Union union)
 {
     unions.Add(union);
 }