static void DumpInstanceCore(AbcInstance instance, string path, bool withScript) { try { using (var writer = Utils.CreateXmlWriter(path)) { writer.WriteStartDocument(); writer.WriteStartElement("abc"); instance.DumpXml(writer); if (withScript) { var abc = instance.Abc; if (abc != null) { var script = instance.Script; if (script != null) { script.DumpXml(writer); } } } writer.WriteEndElement(); writer.WriteEndDocument(); } } catch (Exception e) { Console.WriteLine("Unable to dump instance {0}", instance.FullName); Console.WriteLine(e); } }