private static void ProcessDelete(DeleteCollection delete, KmlFile file) { foreach (Feature source in delete) { if (source.TargetId != null) { if (file.FindObject(source.TargetId) is Feature feature) { // Remove the Feature from the parent, which is either // a Container or Kml if (feature.Parent is Container container) { container.RemoveFeature(source.TargetId); } else { if (feature.Parent is Kml kml) { kml.Feature = null; } } // Also remove it from the file file.RemoveFeature(feature); } } } }
private static void ProcessDelete(DeleteCollection delete, KmlFile file) { foreach (var source in delete) { if (source.TargetId != null) { Feature feature = file.FindObject(source.TargetId) as Feature; if (feature != null) { // Remove the Feature from the parent, which is either // a Container or Kml Container container = feature.Parent as Container; if (container != null) { container.RemoveFeature(source.TargetId); } else { Kml kml = feature.Parent as Kml; if (kml != null) { kml.Feature = null; } } // Also remove it from the file file.RemoveFeature(feature); } } } }