Exemple #1
0
            private async Task CalculateAsync(IntPtr calculation_ptr)
            {
                using (var calculation = new NotifierNotificationHandle(calculation_ptr))
                {
                    ChangeDetails details = null;
                    calculation.GetChanges(nativeDetails =>
                    {
                        if (nativeDetails.HasValue)
                        {
                            var pathOnDisk      = nativeDetails.Value.PathOnDisk;
                            Realm previousRealm = null;
                            if (nativeDetails.Value.previous_realm != IntPtr.Zero)
                            {
                                previousRealm = Realm.GetInstance(new NotifierRealmConfiguration(nativeDetails.Value.previous_realm, pathOnDisk));
                            }

                            var currentRealm = Realm.GetInstance(new NotifierRealmConfiguration(nativeDetails.Value.current_realm, pathOnDisk));

                            details = new ChangeDetails(nativeDetails.Value.Path, nativeDetails.Value.change_sets.AsEnumerable(), previousRealm, currentRealm);
                        }
                    });

                    if (details == null)
                    {
                        return;
                    }

                    try
                    {
                        foreach (var handler in _handlers)
                        {
                            try
                            {
                                if (handler.ShouldHandle(details.RealmPath))
                                {
                                    await handler.HandleChangeAsync(details);
                                }
                            }
                            catch
                            {
                                // Don't skip notifications because someone didn't do a good job at error handling
                                // TODO: figure out a way to propagate those.
                            }
                        }
                    }
                    finally
                    {
                        details.PreviousRealm?.Dispose();
                        details.CurrentRealm.Dispose();
                    }
                }
            }
Exemple #2
0
 public static extern void get_changes(NotifierNotificationHandle handle, IntPtr callback, out NativeException nativeException);