Exemple #1
0
 public void Synchronize()
 {
     foreach (Type type in StorableTypes)
     {
         FileInfo[] files = YamlDataDirectory.GetYamlFiles(type);
         foreach (FileInfo file in files)
         {
             YamlData data = YamlData.Load(type, file, Logger);
             object   dao  = DaoRepository.Query("Name", data.Name).FirstOrDefault();
             if (dao == null)
             {
                 DaoRepository.Save(data.Data);
             }
             else
             {
                 data.FileWins += (o, a) =>
                 {
                     YamlData.YamlDataEventArgs d = (YamlData.YamlDataEventArgs)a;
                     DaoRepository.Save(d.Type, d.Data);
                     FireEvent(FileWins, d);
                 };
                 data.DataWins += (o, a) =>
                 {
                     YamlData.YamlDataEventArgs d = (YamlData.YamlDataEventArgs)a;
                     YamlDataDirectory.Save(file, d.Type, d.Data);
                     FireEvent(DataWins, d);
                 };
                 data.Data = dao;
                 data.Synchronize(type, file);
             }
         }
     }
 }
Exemple #2
0
 protected override object PerformCreate(Type type, object toCreate)
 {
     toCreate = DaoRepository.Create(type, toCreate);
     if (CreateAllFiles)
     {
         FileInfo file = new FileInfo(YamlDataDirectory.GetYamlFilePath(type, toCreate.Property("Name").ToString()));
         YamlDataDirectory.Save(file, type, toCreate);
     }
     return(toCreate);
 }
Exemple #3
0
        public override object Update(Type type, object toUpdate)
        {
            toUpdate = DaoRepository.Update(type, toUpdate);
            FileInfo yamlFile = YamlDataDirectory.GetYamlFile(type, toUpdate);

            if (yamlFile != null)
            {
                YamlDataDirectory.Save(yamlFile, type, toUpdate);
            }
            return(toUpdate);
        }
Exemple #4
0
        private void WriteYaml(Type type, object value)
        {
            FileInfo yamlFile = new FileInfo(YamlDataDirectory.GetYamlFilePath(type, value.Property <string>("Name")));

            YamlDataDirectory.Save(yamlFile, type, value);
        }