void NotificationsHelper.INotifiable.NotifyCallbacks(NotifiableObjectHandleBase.CollectionChangeSet?changes, NativeException?exception) { var managedException = exception?.Convert(); ChangeSet changeset = null; if (changes != null) { var actualChanges = changes.Value; changeset = new ChangeSet( insertedIndices: actualChanges.Insertions.AsEnumerable().Select(i => (int)i).ToArray(), modifiedIndices: actualChanges.Modifications.AsEnumerable().Select(i => (int)i).ToArray(), newModifiedIndices: actualChanges.Modifications_New.AsEnumerable().Select(i => (int)i).ToArray(), deletedIndices: actualChanges.Deletions.AsEnumerable().Select(i => (int)i).ToArray(), moves: actualChanges.Moves.AsEnumerable().Select(m => new ChangeSet.Move((int)m.From, (int)m.To)).ToArray()); } else { _deliveredInitialNotification = true; } foreach (var callback in _callbacks.ToArray()) { callback(this, changeset, managedException); } }
void NotificationsHelper.INotifiable.NotifyCallbacks(NotifiableObjectHandleBase.CollectionChangeSet?changes, NativeException?exception) { var managedException = exception?.Convert(); if (managedException != null) { Realm.NotifyError(managedException); } else if (changes.HasValue) { foreach (int propertyIndex in changes.Value.Properties.AsEnumerable()) { // Due to a yet another Mono compiler bug, using LINQ fails here :/ var i = 0; foreach (var property in ObjectSchema) { // Backlinks should be ignored. See Realm.CreateRealmObjectMetadata if (property.Type.IsComputed()) { continue; } if (i == propertyIndex) { RaisePropertyChanged(property.PropertyInfo?.Name ?? property.Name); break; } ++i; } } } }
void NotificationsHelper.INotifiable.NotifyCallbacks(NotifiableObjectHandleBase.CollectionChangeSet?changes, NativeException?exception) { var managedException = exception?.Convert(); if (managedException != null) { Realm.NotifyError(managedException); } else if (changes.HasValue) { foreach (var propertyIndex in changes.Value.Properties.AsEnumerable()) { var property = ObjectSchema.ElementAtOrDefault((int)propertyIndex); RaisePropertyChanged(property.PropertyInfo?.Name ?? property.Name); } } }
/// <inheritdoc/> void INotifiable <NotifiableObjectHandleBase.CollectionChangeSet> .NotifyCallbacks(NotifiableObjectHandleBase.CollectionChangeSet?changes, NativeException?exception) { var managedException = exception?.Convert(); if (managedException != null) { Realm.NotifyError(managedException); } else if (changes.HasValue) { foreach (int propertyIndex in changes.Value.Properties.AsEnumerable()) { // Due to a yet another Mono compiler bug, using LINQ fails here :/ var i = 0; foreach (var property in ObjectSchema) { // Backlinks should be ignored. See Realm.CreateRealmObjectMetadata if (property.Type.IsComputed()) { continue; } if (i == propertyIndex) { RaisePropertyChanged(property.PropertyInfo?.Name ?? property.Name); break; } ++i; } } if (changes.Value.Deletions.AsEnumerable().Any()) { RaisePropertyChanged(nameof(IsValid)); if (!IsValid) { // We can proactively unsubscribe because the object has been deleted UnsubscribeFromNotifications(); } } } }
void RealmResultsNativeHelper.Interface.NotifyCallbacks(ResultsHandle.CollectionChangeSet?changes, NativeException?exception) { var managedException = exception?.Convert(); ChangeSet changeset = null; if (changes != null) { var actualChanges = changes.Value; changeset = new ChangeSet( insertedIndices: actualChanges.Insertions.AsEnumerable().Select(i => (int)i).ToArray(), modifiedIndices: actualChanges.Modifications.AsEnumerable().Select(i => (int)i).ToArray(), deletedIndices: actualChanges.Deletions.AsEnumerable().Select(i => (int)i).ToArray()); } foreach (var callback in _callbacks) { callback(this, changeset, managedException); } }
void INotifiable <DictionaryHandle.DictionaryChangeSet> .NotifyCallbacks(DictionaryHandle.DictionaryChangeSet?changes, NativeException?exception) { var managedException = exception?.Convert(); DictionaryChangeSet changeset = null; if (changes != null) { var actualChanges = changes.Value; changeset = new DictionaryChangeSet( insertedKeys: actualChanges.Insertions.AsEnumerable().Select(v => v.AsString()).ToArray(), modifiedKeys: actualChanges.Modifications.AsEnumerable().Select(v => v.AsString()).ToArray()); } else { _deliveredInitialKeyNotification = true; } foreach (var callback in _keyCallbacks.ToArray()) { callback(this, changeset, managedException); } }
public static void ExceptionThrower(NativeException exception) { throw exception.Convert(); }