ConnectCore( CurrentListener <TTarget> listener, CancellationTokenSource cts ) { source.Connect(new MapCurrentListener(this, listener, cts)); }
BaseOperatorCurrentListener( CurrentListener <TTarget> listener, CancellationTokenSource cts ) { Listener = listener; CancellationTokenSource = cts; }
MapCurrentListener( MapCurrent <TSource, TTarget> parent, CurrentListener <TTarget> listener, CancellationTokenSource cts ) : base(listener, cts) { this.parent = parent; }
public void Connect(CurrentListener <TValue> listener) { listener.CancellationToken.ThrowIfCancellationRequested(); var cts = new CancellationTokenSource(); var ctr = listener.CancellationToken.Register(cts.Cancel); cts.Token.Register(ctr.Dispose); ConnectCore(listener, cts); }
public bool Equals(CurrentListener other) { if (ReferenceEquals(this, other)) { return(true); } if (ReferenceEquals(other, null)) { return(false); } return(other.Equals(listener)); }
void Current.ConnectNongeneric(CurrentListener listener) { Connect(listener.Box <TValue>()); }
public abstract void Connect(CurrentListener <TValue> listener);
public BoxCurrentListener(CurrentListener listener) { this.listener = listener; }
ConnectCore( CurrentListener <TValue> listener, CancellationTokenSource cts );
public override void Connect(CurrentListener <TValue> listener) { listener.CancellationToken.ThrowIfCancellationRequested(); switch (enumerable) { case IList <TValue> list: var count = list.Count; for (var i = 0; i < count; i++) { listener.CancellationToken.ThrowIfCancellationRequested(); var value = default(TValue); var valueExists = default(bool); try { value = list[i]; valueExists = true; } catch (Exception e) { listener.OnError(e); return; } if (!valueExists) { listener.OnCompleted(); return; } listener.OnValue(value); } break; default: var enumerator = default(IEnumerator <TValue>); try { enumerator = enumerable.GetEnumerator(); } catch (Exception e) { listener.OnError(e); return; } while (true) { listener.CancellationToken.ThrowIfCancellationRequested(); var value = default(TValue); var valueExists = default(bool); try { if (enumerator.MoveNext()) { value = enumerator.Current; valueExists = true; } } catch (Exception e) { listener.OnError(e); return; } if (!valueExists) { listener.OnCompleted(); return; } listener.OnValue(value); } ; } }
/// <summary> /// Creates a listener which boxes and forwards values. /// </summary> /// <typeparam name="X"></typeparam> /// <param name="this"></param> /// <returns></returns> public static CurrentListener <X> Box <X>(this CurrentListener @this) { return(new BoxCurrentListener <X>(@this)); }