public void Save(String filePath, ObjectsWrapper wrapper)
 {
     this.Logger().InfoFormat("Saving file '{0}'.", filePath);
     if (wrapper != null)
     {
         var xmlSerializer = new XmlSerializer(typeof(ObjectsWrapper));
         StreamWriter streamWriter = null;
         try
         {
             streamWriter = new StreamWriter(filePath);
             xmlSerializer.Serialize(streamWriter, wrapper);
             this.Logger().InfoFormat("File '{0}' saved.", filePath);
         }
         catch (Exception e)
         {
             this.Logger().Error(e.Message);
             this.Logger().Error(e.Source);
         }
         finally
         {
             if (streamWriter != null)
             {
                 streamWriter.Close();
             }
         }
     }
 }
示例#2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     //String filePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
     ObjectsWrapper wrapper = new ObjectsWrapper();
     wrapper.Videos = this._videos.ToList();
     //this._controller.Save(filePath, wrapper);
 }
示例#3
0
 public ObjectsWrapper GetObjectsFromFile()
 {
     if (_objectsWrapper == null)
     {
         var repository = DependencyFactory.Resolve<IVideoRepository>();
         _objectsWrapper = repository.Load(FileSystemHelper.GetDefaultFileName());
     }
     return _objectsWrapper;
 }
 public ObjectsWrapper Load(String filePath)
 {
     ObjectsWrapper wrapper = new ObjectsWrapper();
     try
     {
         this.Logger().InfoFormat("Loading file '{0}'.", filePath);
         var xmlSerializer = new XmlSerializer(typeof(ObjectsWrapper));
         if (File.Exists(filePath))
         {
             var streamReader = new StreamReader(filePath);
             wrapper = xmlSerializer.Deserialize(streamReader) as ObjectsWrapper;
             streamReader.Close();
             this.Logger().InfoFormat("File '{0}' loaded.", filePath);
         }
     }
     catch (Exception e)
     {
         this.Logger().Error(e.Message);
         this.Logger().Error(e.Source);
     }
     return wrapper;
 }
示例#5
0
 public void Save(String filePath, ObjectsWrapper wrapper)
 {
     var repository = DependencyFactory.Resolve<IVideoRepository>();
     repository.Save(filePath, wrapper);
 }
示例#6
0
 public void Save(ObjectsWrapper wrapper)
 {
     this.Save(FileSystemHelper.GetDefaultFileName(), wrapper);
 }