private static void WriteFile(StreamWriter file, KmlItem item, int indent) { bool ghost = item is KmlGhostNode; if (!ghost) { file.WriteLine(item.ToLine(indent)); } if (item is KmlNode) { int newIndent = indent; KmlNode node = (KmlNode)item; if (!ghost) { file.WriteLine(new KmlBegin().ToLine(indent)); newIndent = indent + 1; } foreach (KmlItem child in node.AllItems) { WriteFile(file, child, newIndent); } if (!ghost) { file.WriteLine(new KmlEnd().ToLine(indent)); } } }
/// <summary> /// Writes serialized KmlItem into writer /// </summary> /// <param name="writer">Writer used to write serialized item.</param> /// <param name="item">Item for serialization.</param> /// <param name="indent">Default indent.</param> public static void WriteItem(TextWriter writer, KmlItem item, int indent) { bool ghost = item is KmlGhostNode; if (!ghost) { writer.WriteLine(item.ToLine(indent)); } if (item is KmlNode) { int newIndent = indent; KmlNode node = (KmlNode)item; if (!ghost) { writer.WriteLine(new KmlBegin().ToLine(indent)); newIndent = indent + 1; } foreach (KmlItem child in node.AllItems) { WriteItem(writer, child, newIndent); } if (!ghost) { writer.WriteLine(new KmlEnd().ToLine(indent)); } } }