Example #1
0
        public override bool Delete <T>(T toDelete)
        {
            bool result = DaoRepository.Delete <T>(toDelete);

            if (result)
            {
                result = YamlDataDirectory.Delete <T>(toDelete);
            }
            return(result);
        }
Example #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);
 }
Example #3
0
        protected override bool PerformDelete(Type type, object toDelete)
        {
            bool result = DaoRepository.Delete(type, toDelete);

            if (result)
            {
                result = YamlDataDirectory.Delete(type, toDelete);
            }
            return(result);
        }
Example #4
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);
        }
Example #5
0
 public override IEnumerable <object> RetrieveAll(Type type)
 {
     foreach (object o in DaoRepository.RetrieveAll(type))
     {
         yield return(o);
     }
     foreach (object o in YamlDataDirectory.Load(type))
     {
         yield return(o);
     }
 }
Example #6
0
 private object GetLatest(object dao)
 {
     if (dao != null)
     {
         FileInfo yamlFile = YamlDataDirectory.GetYamlFile(dao.GetType(), dao);
         if (yamlFile != null)
         {
             YamlData data = new YamlData(dao);
             return(data.Newer(yamlFile));
         }
     }
     return(dao);
 }
Example #7
0
 public override IEnumerable <object> Query(Type type, Func <object, bool> predicate)
 {
     foreach (object o in DaoRepository.Query(type, predicate))
     {
         yield return(o);
     }
     foreach (object o in YamlDataDirectory.Load(type))
     {
         if (predicate(o))
         {
             yield return(o);
         }
     }
 }
Example #8
0
 public override IEnumerable <T> Query <T>(Func <T, bool> query)
 {
     foreach (T val in DaoRepository.Query(query))
     {
         yield return(val);
     }
     foreach (YamlDataFile val in YamlDataDirectory.Load(typeof(T)))
     {
         T copy = val.Data.CopyAs <T>();
         if (query(copy))
         {
             yield return(copy);
         }
     }
 }
Example #9
0
        private void WriteYaml(Type type, object value)
        {
            FileInfo yamlFile = new FileInfo(YamlDataDirectory.GetYamlFilePath(type, value.Property <string>("Name")));

            YamlDataDirectory.Save(yamlFile, type, value);
        }
Example #10
0
 public YamlRepository(string rootDirectory, DaoRepository daoRepo, ILogger logger = null) : base(rootDirectory)
 {
     DaoRepository     = daoRepo;
     DataDirectoryName = "Yaml";
     YamlDataDirectory = new YamlDataDirectory(DataDirectory, logger);
 }