public static bool SaveToStream(BinaryWriter outputWriter, Model model) { ModelStorage storage = new ModelStorage(string.Empty, model); if (!storage.Write(outputWriter)) { Debug.Assert(false, "Cannot write a model file!"); return(false); } return(true); }
public static bool SaveToFile(string filePath, Model model) { if (string.IsNullOrEmpty(filePath)) { return(false); } ModelStorage storage = new ModelStorage(filePath, model); using (FileStream stream = new FileStream(storage.LibraryPath, FileMode.Create)) { using (BinaryWriter outputWriter = new BinaryWriter(stream, storage.Encoding)) { if (!storage.Write(outputWriter)) { Debug.Assert(false, "Cannot write a model file!"); return(false); } } } return(true); }