/// <summary> /// Saves the object to memory stream so the <see cref="IModel.IsDirty" /> property is set to false. /// </summary> /// <param name="obj">The object.</param> /// <param name="serializer">The serializer.</param> /// <param name="configuration">The configuration.</param> internal static void SaveObjectToDummyMemoryStream(this ISavableModel obj, ISerializer serializer, ISerializationConfiguration configuration = null) { using (var memoryStream = new MemoryStream()) { obj.Save(memoryStream, serializer, configuration); } }
/// <summary> /// Saves the object to memory stream so the <see cref="IModel.IsDirty"/> property is set to false. /// </summary> /// <param name="obj">The object.</param> internal static void SaveObjectToMemoryStream(ISavableModel obj) { using (var memoryStream = new MemoryStream()) { obj.Save(memoryStream); } }
/// <summary> /// Saves the object to a file using a specific formatting. /// </summary> /// <param name="model">The model to save.</param> /// <param name="fileName">Filename of the file that will contain the serialized data of this object.</param> /// <param name="serializer">The serializer to use.</param> /// <param name="configuration">The configuration.</param> public static void Save(this ISavableModel model, string fileName, ISerializer serializer, ISerializationConfiguration configuration = null) { var fileInfo = new FileInfo(fileName); if (!Directory.Exists(fileInfo.DirectoryName)) { Directory.CreateDirectory(fileInfo.DirectoryName); } using (Stream stream = new FileStream(fileName, FileMode.Create)) { model.Save(stream, serializer, configuration); } }
/// <summary> /// Saves the object to memory stream so the <see cref="IModel.IsDirty" /> property is set to false. /// </summary> /// <param name="obj">The object.</param> /// <param name="configuration">The configuration.</param> internal static void SaveObjectToMemoryStream(ISavableModel obj, ISerializationConfiguration configuration = null) { using (var memoryStream = new MemoryStream()) { obj.Save(memoryStream, configuration); } }