Пример #1
0
        public static List <T> ReadListFromStore <T>(string fileName, StoreType store, out string strError)
        {
            List <T> entities = null;

            try
            {
                fileName += FileExtension;
                var fullPath = Path.Combine(GetFolderPath(store), fileName);
                if (File.Exists(fullPath))
                {
                    var data = FileIoHelper.ReadFromTextFile(fullPath, out strError);
                    entities = SerializationHelper.DeserializeFromJsonString <List <T> >(data);
                }
                else
                {
                    strError = "Le fichier spécifié n'existe pas";
                }
            }
            catch (Exception e)
            {
                strError = ExceptionHelper.GetMessageFromException(e);
                //ElLogger.LogError(strError);
            }
            return(entities ?? new List <T>());
        }
Пример #2
0
 public static void WriteListToStore <T>(List <T> entities, string fileName, StoreType store, out string strError)
 {
     try
     {
         fileName += FileExtension;
         var fullPath = Path.Combine(GetFolderPath(store), fileName);
         var data     = SerializationHelper.SerializeToJson(entities);
         FileIoHelper.WriteToTextFile(fullPath, data, out strError);
     }
     catch (Exception e)
     {
         strError = ExceptionHelper.GetMessageFromException(e);
         //ElLogger.LogError(strError);
     }
 }
Пример #3
0
        public static T ReadFromStore <T>(string fileName, StoreType store, out string strError)
        {
            var entity = default(T);

            try
            {
                fileName += FileExtension;
                var fullPath = Path.Combine(GetFolderPath(store), fileName);
                var data     = FileIoHelper.ReadFromTextFile(fullPath, out strError);
                if (!string.IsNullOrEmpty(data))
                {
                    entity = SerializationHelper.DeserializeFromJsonString <T>(data);
                }
            }
            catch (Exception e)
            {
                strError = ExceptionHelper.GetMessageFromException(e);
                //ElLogger.LogError(strError);
            }
            return(entity);
        }