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); } } } }
/// <summary> /// Provides in-place (destructive) processing of the <see cref="Update"/>. /// </summary> /// <param name="update">The update instance.</param> /// <param name="file"> /// A KmlFile containing the <c>Update</c> and the update targets. /// </param> /// <exception cref="ArgumentNullException">file is null.</exception> public static void Process(this Update update, KmlFile file) { if (file == null) { throw new ArgumentNullException("file"); } foreach (var child in update.Updates) { ChangeCollection change = child as ChangeCollection; if (change != null) { ProcessChange(change, file); continue; } CreateCollection create = child as CreateCollection; if (create != null) { ProcessCreate(create, file); continue; } DeleteCollection delete = child as DeleteCollection; if (delete != null) { ProcessDelete(delete, file); } } }
public void TestManyDeletes() { const int NumberOfFolders = 100; var folder = new Folder(); for (int i = 0; i < NumberOfFolders; ++i) { folder.AddFeature(CreateFeature(i, true)); // Add the features with their Id set } Assert.That(folder.Features.Count(), Is.EqualTo(NumberOfFolders)); var file = KmlFile.Create(folder, false); var update = new Update(); for (int i = 0; i < NumberOfFolders; ++i) { var delete = new DeleteCollection { CreateFeature(i, false) // This time set the TargetId }; update.AddUpdate(delete); } update.Process(file); Assert.That(folder.Features.Count(), Is.EqualTo(0)); }
private void UpdateButtonState() { NewCollection.RaiseCanExecuteChanged(); OpenCollection.RaiseCanExecuteChanged(); SaveCollection.RaiseCanExecuteChanged(); EditCollection.RaiseCanExecuteChanged(); DeleteCollection.RaiseCanExecuteChanged(); CommitCollection.RaiseCanExecuteChanged(); ReviewCollection.RaiseCanExecuteChanged(); }
private void UpdateButtonState() { NewCollection.RaiseCanExecuteChanged(); OpenCollection.RaiseCanExecuteChanged(); SaveCollection.RaiseCanExecuteChanged(); EditCollection.RaiseCanExecuteChanged(); DeleteCollection.RaiseCanExecuteChanged(); CommitCollection.RaiseCanExecuteChanged(); ReviewCollection.RaiseCanExecuteChanged(); ViewRecordCommand.RaiseCanExecuteChanged(); //IsSaveVisible = FormArgs == null ? false : FormArgs.HasNoRecords == false && FormArgs.ViewMode != FormMode.DELETEMODE; OnPropertyChanged("IsCommitVisible"); }
private void Delete(string obj) { var msg = new DeleteModeArgs { ViewName = FormArgs.ViewBackingClass }; eventAggregator.GetEvent <DeleteModeArgsEvent>().Publish(msg); if (FormArgs.ViewMode.Peek() == FormMode.SAVED) { FormArgs.ViewMode.Pop(); FormArgs.ViewMode.Push(FormMode.WIP); } DeleteCollection.RaiseCanExecuteChanged(); SaveCollection.RaiseCanExecuteChanged(); UpdateButtonState(); }
public RequestDeleteCollection(ScorocodeSdkStateHolder stateHolder, string collectionId) : base(stateHolder) { this.collection = new DeleteCollection(collectionId); }
public void TestManyDeletes() { const int NumberOfFolders = 100; var folder = new Folder(); for (int i = 0; i < NumberOfFolders; ++i) { folder.AddFeature(CreateFeature(i, true)); // Add the features with their Id set } Assert.That(folder.Features.Count(), Is.EqualTo(NumberOfFolders)); KmlFile file = KmlFile.Create(folder, false); var update = new Update(); for (int i = 0; i < NumberOfFolders; ++i) { var delete = new DeleteCollection(); delete.Add(CreateFeature(i, false)); // This time set the TargetId update.AddUpdate(delete); } update.Process(file); Assert.That(folder.Features.Count(), Is.EqualTo(0)); }
public Task DeleteCollection(DeleteCollection command) => Send(command);
/// <summary> /// Adds the specified <see cref="DeleteCollection"/> to <see cref="Updates"/>. /// </summary> /// <param name="update">The <c>Delete</c> to add.</param> /// <exception cref="ArgumentNullException">update is null.</exception> /// <exception cref="InvalidOperationException"> /// update belongs to another <see cref="Element"/>. /// </exception> public void AddUpdate(DeleteCollection update) { this.AddChild(update); }