Browse Source

Delegate invocation using C# 6.0 syntax.

Bart De Smet 8 years ago
parent
commit
e46f1639b0

+ 1 - 3
Rx.NET/Source/src/System.Reactive/Concurrency/SchedulerOperation.cs

@@ -151,9 +151,7 @@ namespace System.Reactive.Concurrency
             if (w != null)
                 w.Dispose();
 
-            var c = _continuation;
-            if (c != null)
-                c();
+            _continuation?.Invoke();
         }
     }
 }

+ 1 - 5
Rx.NET/Source/src/System.Reactive/Disposables/AnonymousDisposable.cs

@@ -37,11 +37,7 @@ namespace System.Reactive.Disposables
         /// </summary>
         public void Dispose()
         {
-            var dispose = Interlocked.Exchange(ref _dispose, null);
-            if (dispose != null)
-            {
-                dispose();
-            }
+            Interlocked.Exchange(ref _dispose, null)?.Invoke();
         }
     }
 }

+ 2 - 6
Rx.NET/Source/src/System.Reactive/Internal/HostLifecycleService.cs

@@ -62,16 +62,12 @@ namespace System.Reactive.PlatformServices
 
         private static void OnSuspending(object sender, HostSuspendingEventArgs e)
         {
-            var suspending = Suspending;
-            if (suspending != null)
-                suspending(sender, e);
+            Suspending?.Invoke(sender, e);
         }
 
         private static void OnResuming(object sender, HostResumingEventArgs e)
         {
-            var resuming = Resuming;
-            if (resuming != null)
-                resuming(sender, e);
+            Resuming?.Invoke(sender, e);
         }
 
         private static IHostLifecycleNotifications InitializeNotifications()

+ 1 - 3
Rx.NET/Source/src/System.Reactive/Internal/SystemClock.Default.cs

@@ -100,9 +100,7 @@ namespace System.Reactive.PlatformServices
             var diff = now - (_lastTime + _period);
             if (Math.Abs(diff.TotalMilliseconds) >= MAXERROR)
             {
-                var scc = _systemClockChanged;
-                if (scc != null)
-                    scc(this, new SystemClockChangedEventArgs(_lastTime + _period, now));
+                _systemClockChanged?.Invoke(this, new SystemClockChangedEventArgs(_lastTime + _period, now));
 
                 NewTimer();
             }

+ 6 - 9
Rx.NET/Source/src/System.Reactive/Platforms/UWP/Foundation/AsyncInfoToObservableBridge.cs

@@ -22,17 +22,14 @@ namespace System.Reactive.Windows.Foundation
 
             _subject = new AsyncSubject<TResult>();
 
-            if (onProgress != null)
+            onProgress?.Invoke(info, (iai, p) =>
             {
-                onProgress(info, (iai, p) =>
-                {
-                    if (multiValue && getResult != null)
-                        _subject.OnNext(getResult(iai));
+                if (multiValue && getResult != null)
+                    _subject.OnNext(getResult(iai));
 
-                    if (progress != null)
-                        progress.Report(p);
-                });
-            }
+                if (progress != null)
+                    progress.Report(p);
+            });
 
             Done(info, info.Status, true);
         }