示例#1
0
        public bool GetFromElement(XElement xTable, out RelationsTable table)
        {
            table = RelationsTable.GetTable();
            table.Clear();
            try
            {
                foreach (XElement xRelation in xTable.Elements("relation"))
                {
                    int       firstID  = Int32.Parse(xRelation.Attribute("firstPerson").Value);
                    int       secondID = Int32.Parse(xRelation.Attribute("secondPerson").Value);
                    Relatives relation = (Relatives)Enum.Parse(typeof(Relatives), xRelation.Attribute("relation").Value);

                    PersonList personList = PersonList.GetPersonList(null);
                    Person     fPerson;
                    Person     sPerson;
                    if ((personList.GetPersonFromID(firstID, out fPerson)) &&
                        (personList.GetPersonFromID(secondID, out sPerson)))
                    {
                        table.SetRelationBetweenPersons(fPerson, sPerson, relation);
                    }
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#2
0
        public bool GetFromElement(XElement xTable, out RelationsTable table)
        {
            table = RelationsTable.GetTable();
            table.Clear();
            try
            {
                foreach (XElement xRelation in xTable.Elements("relation"))
                {
                    int firstID = Int32.Parse(xRelation.Attribute("firstPerson").Value);
                    int secondID = Int32.Parse(xRelation.Attribute("secondPerson").Value);
                    Relatives relation = (Relatives)Enum.Parse(typeof(Relatives), xRelation.Attribute("relation").Value);

                    PersonList personList = PersonList.GetPersonList(null);
                    Person fPerson;
                    Person sPerson;
                    if((personList.GetPersonFromID(firstID,out fPerson))
                        &&(personList.GetPersonFromID(secondID,out sPerson)))
                    {
                        table.SetRelationBetweenPersons(fPerson, sPerson, relation);
                    }
                }
                return true;
            }
            catch
            {

                return false;
            }
        }