private void UpdateLocationInfo(IDocumentSnapshot document, GeoPoint location) { var key = document.Id; _locationInfos.TryGetValue(key, out var oldInfo); var isNew = oldInfo == null; var changedLocation = oldInfo != null && !Equals(oldInfo.Location, location); var wasInQuery = oldInfo != null && oldInfo.InGeoQuery; var isInQuery = LocationIsInQuery(location); if ((isNew || !wasInQuery) && isInQuery) { OnDocumentEntered?.Invoke(this, new DocumentEventArgs <T>(document.ToObject <T>(), location)); } else if (!isNew && isInQuery) { if (changedLocation) { OnDocumentMoved?.Invoke(this, new DocumentEventArgs <T>(document.ToObject <T>(), location)); } OnDocumentChanged?.Invoke(this, new DocumentEventArgs <T>(document.ToObject <T>(), location)); } else if (wasInQuery && !isInQuery) { OnDocumentExited?.Invoke(this, new DocumentEventArgs <T>(document.ToObject <T>())); } var newInfo = new LocationInfo(location, LocationIsInQuery(location), document); _locationInfos.Add(key, newInfo); }
public void DocumentChanged(IEnumerable <string> transactionNames, string documentTitle, IEnumerable <int> addedElementIds, IEnumerable <int> modifiedElementIds, IEnumerable <int> deletedElementIds) { // Make sure someone is listening to event OnDocumentChanged?.Invoke(new DocumentChangedEventArgs(transactionNames, documentTitle, addedElementIds, modifiedElementIds, deletedElementIds)); }