/// <summary> /// Saves to stream. /// </summary> /// <param name="model">The model.</param> /// <param name="stream">The stream.</param> public static void SaveToStream(Model model, Stream stream) { var serializer = new DataContractSerializer(typeof(Model)); serializer.WriteObject(stream, model); }
/// <summary> /// Saves to XML file. /// </summary> /// <param name="model">The model.</param> /// <param name="filePath">The file path.</param> public static void SaveToXmlFile(Model model, string filePath) { var serializer = new DataContractSerializer(typeof (Model)); using (var file = new FileStream(filePath, FileMode.Create)) { serializer.WriteObject(file, model); } }