Ejemplo n.º 1
0
 private bool LoadIndexFile(string filePath)
 {
     if (!File.Exists(filePath))
     {
         Core.Log.Warning("The Index file: {0} doesn't exist.", filePath);
         return(false);
     }
     try
     {
         Core.Log.InfoBasic("Loading Index File: {0}", filePath);
         var index = _indexSerializer.DeserializeFromFile <List <StorageItemMeta> >(filePath);
         if (index != null)
         {
             var pairEnumerable = index.Select(i => new KeyValuePair <string, StorageItemMeta>(i.Key, i)).ToArray();
             _metas = new ConcurrentDictionary <string, StorageItemMeta>(pairEnumerable);
             foreach (var valuePair in pairEnumerable)
             {
                 _globalMetas.TryAdd(valuePair.Key, valuePair.Value);
             }
             return(true);
         }
     }
     catch (Exception ex)
     {
         Core.Log.Write(ex);
     }
     return(false);
 }
Ejemplo n.º 2
0
 private Settings DeserializeSettingsBackgroundTask()
 {
     if (!File.Exists(SettingsFilePath))
     {
         Logger.Warn("Settings file does not exist");
         return(null);
     }
     try
     {
         //var serializer = new XmlSerializer<Settings>();
         var serializer = new BinarySerializer <Settings>();
         return(serializer.DeserializeFromFile(SettingsFilePath));
     }
     catch (Exception exception)
     {
         Logger.Error(exception);
         return(null);
     }
 }
 private Settings DeserializeSettingsBackgroundTask()
 {
     if (!File.Exists(SettingsFilePath))
     {
         Logger.Warn("Settings file does not exist");
         return null;
     }
     try
     {
         //var serializer = new XmlSerializer<Settings>();
         var serializer = new BinarySerializer<Settings>();
         return serializer.DeserializeFromFile(SettingsFilePath);
     }
     catch (Exception exception)
     {
         Logger.Error(exception);
         return null;
     }
 }