public static void Serialize(DnaDrawing drawing, string fileName) { if (fileName == null) { return; } if (fileName.EndsWith("xml")) { try { var serializer = new XmlSerializer(drawing.GetType()); using (var writer = new FileStream(fileName, FileMode.Create)) { serializer.Serialize(writer, drawing); } } catch (Exception) { } } else { SerializeBinary(drawing, fileName); } }