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(); } } } }
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); }
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; }
public void Save(String filePath, ObjectsWrapper wrapper) { var repository = DependencyFactory.Resolve<IVideoRepository>(); repository.Save(filePath, wrapper); }
public void Save(ObjectsWrapper wrapper) { this.Save(FileSystemHelper.GetDefaultFileName(), wrapper); }