Esempio n. 1
0
        public void LoadFromXml(XDocument doc)
        {
            if (doc.Root != null) Name = doc.Root.Attribute("Name").Value;
            if (doc.Root != null) ProjectId = Convert.ToInt64(doc.Root.Attribute("ProjectId").Value);
            if (doc.Root != null) SynCode = Convert.ToInt64(doc.Root.Attribute("SynCode").Value);

            if (doc.Root != null)
            {
                switch (doc.Root.Attribute("Status").Value)
                {
                    case "NotSet":
                    {
                        Status = CardStatus.NotSet;
                    }
                        break;
                    case "Verifyed":
                    {
                        Status = CardStatus.Verifyed;
                    }
                        break;
                    case "Assigned":
                    {
                        Status = CardStatus.Assigned;
                    }
                        break;
                    case "Archived":
                    {
                        Status = CardStatus.Archived;
                    }
                        break;
                }
            }

            _contacts.Clear();
            var list = doc.Descendants("Contacts").First();
            foreach (var variable in list.Elements())
            {
                if (variable.Name == "Phone")
                {
                    var a =new Phone();
                    a.LoadFromXml(variable);
                    _contacts.Add(a);
                    //_contacts.Add(new Phone(variable.Attribute("Phone").Value, variable.Attribute("PhoneZone").Value));
                }
                else if (variable.Name == "Mail")
                {
                    var a=new Mail();
                    a.LoadFromXml(variable);
                    _contacts.Add(a);
                    //_contacts.Add(new Mail(variable.Attribute("Mail").Value, variable.Attribute("Alias").Value));
                }
                else
                {
                    throw  new Exception("Contact in input file is not a mail or a phone!");
                }
            }
        }
Esempio n. 2
0
 public void AddPhone(string newContact, string newPhoneZone)
 {
     Contact tempPhone = new Phone(newContact, newPhoneZone);
     _contacts.Add(tempPhone);
 }