Debian Codegraph @

external/rx/Rx/NET/Source/Tests.System.Reactive/Extensions.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
3 using System;
4 using System.Collections.Generic;
5 using System.Reactive.Concurrency;
6 using System.Reactive.Disposables;
7 using Microsoft.Reactive.Testing;
8
9 namespace ReactiveTests
10 {
11 public static class Extensions
12 {
13 //public static IDisposable ScheduleAbsolute(this TestScheduler scheduler, long time, Action action)
14 //{
15 // return scheduler.ScheduleAbsolute(default(object), time, (scheduler1, state1) => { action(); return Disposable.Empty; });
16 //}
17
18 //public static IDisposable ScheduleRelative(this TestScheduler scheduler, long time, Action action)
19 //{
20 // return scheduler.ScheduleRelative(default(object), time, (scheduler1, state1) => { action(); return Disposable.Empty; });
21 //}
22
23 public static void EnsureTrampoline(this CurrentThreadScheduler scheduler, Action action)
24 {
25 if (scheduler.ScheduleRequired)
26 scheduler.Schedule(action);
27 else
28 action();
29 }
30
31 public static IEnumerable<R> Zip<T1, T2, R>(this IEnumerable<T1> source1, IEnumerable<T2> source2, Func<T1, T2, R> f)
32 {
33 using (var e1 = source1.GetEnumerator())
34 using (var e2 = source2.GetEnumerator())
35 while (e1.MoveNext() && e2.MoveNext())
36 yield return f(e1.Current, e2.Current);
37 }
38 }
39 }