示例#1
0
        public List <IUIPerson> Restore(string filename)
        {
            var tmpGenealogyMaster = new GenealogyMaster();

            if (!File.Exists(filename))
            {
                return(null);
            }

            string json = null;

            using (var sr = new StreamReader(filename))
            {
                json = sr.ReadToEnd();
            }

            var deserializedPersons = JsonConvert.DeserializeObject <List <SerializablePerson> >(json);

            foreach (var serializablePerson in deserializedPersons)
            {
                tmpGenealogyMaster.AddPerson(serializablePerson.ToUIPerson(), autoDefineGender: false);
            }

            foreach (var serializablePerson in deserializedPersons)
            {
                var guids = serializablePerson.ParentGuids;
                foreach (var parentId in guids)
                {
                    tmpGenealogyMaster.ParentRelationManager.AddParent(tmpGenealogyMaster.GetPersonById(serializablePerson.Id), tmpGenealogyMaster.GetPersonById(parentId));
                }
            }

            return(tmpGenealogyMaster.GetAll());
        }
 public void Persist(GenealogyMaster genealogyMaster)
 {
     persistorCore.Persist(this.filename, this.backupFile, genealogyMaster.GetAll());
 }