public virtual Task <bool> TryDeleteCoordinateAsync(TKey key, CancellationToken cancellationToken) { bool wasRemoved = knownCoordinates.TryRemove(key, out ISpatialCoordinate coordinate); if (wasRemoved) { CoordinateRemoved?.Invoke(coordinate); } return(Task.FromResult(wasRemoved)); }
/// <summary> /// Removes a tracked coordinate from this service. /// </summary> /// <param name="id">The ide of the coordinate to remove.</param> /// <remarks>Will throw if coordinate was not tracked by this service, checking is possible throuhg <see cref="knownCoordinates"/> field.</remarks> protected void OnRemoveCoordinate(TKey id) { ThrowIfDisposed(); if (knownCoordinates.TryRemove(id, out ISpatialCoordinate coordinate)) { CoordinateRemoved?.Invoke(coordinate); } else { throw new InvalidOperationException($"Coordinate with id '{id}' was not previously registered."); } }