protected FilterSectionSubjectBase(IPushObservable <TIn> observable, KeepingState initialState, Func <TIn, SwitchBehavior> switchToKeep, Func <TIn, SwitchBehavior> switchToIgnore) : base(observable.CancellationToken) { this.Subscription = observable.Subscribe(HandlePushValue, this.Complete, this.PushException); SwitchToKeep = switchToKeep; SwitchToIgnore = switchToIgnore; CurrentState = initialState; }
public FilterSectionSubject(IPushObservable <TIn> observable, KeepingState initialState, Func <TIn, SwitchBehavior> switcher, Func <TIn, int, TOut> resultSelector) : this(observable, resultSelector) { _currentState = initialState; _switchToKeep = switcher; _switchToIgnore = switcher; _sectionIndex = _currentState == KeepingState.Ignore ? -1 : 0; }
private FilterSectionSubject(IPushObservable <TIn> observable, Func <TIn, int, TOut> resultSelector) { _resultSelector = resultSelector; this._subscription = observable.Subscribe(HandlePushValue, this.Complete, this.PushException); _currentState = KeepingState.Ignore; _sectionIndex = _currentState == KeepingState.Ignore ? -1 : 0; }
private void ProcessCurrentKeep(TIn value) { var switchRes = _switchToIgnore(value); switch (switchRes) { case SwitchBehavior.SwitchIgnoreCurrent: _currentState = KeepingState.Ignore; break; case SwitchBehavior.SwitchKeepCurrent: _currentState = KeepingState.Ignore; this.PushValue(this._resultSelector(value, _sectionIndex)); break; default: if (_currentState == KeepingState.Keep) { this.PushValue(this._resultSelector(value, _sectionIndex)); } break; } }
public FilterSectionSubject(IPushObservable <TIn> observable, KeepingState initialState, Func <TIn, SwitchBehavior> switcher, Func <TIn, int, TOut> resultSelector) : this(observable, initialState, switcher, switcher, resultSelector) { }
public static IPushObservable <TOut> FilterSection <TIn, TOut>(this IPushObservable <TIn> observable, KeepingState initialState, Func <TIn, SwitchBehavior> switchToKeep, Func <TIn, SwitchBehavior> switchToIgnore, Func <TIn, int, TOut> resultSelector) { return(new FilterSectionSubject <TIn, TOut>(observable, initialState, switchToKeep, switchToIgnore, resultSelector)); }
public FilterSectionSubject(IPushObservable <TIn> observable, KeepingState initialState, Func <TIn, SwitchBehavior> switchToKeep, Func <TIn, SwitchBehavior> switchToIgnore, Func <TIn, int, TOut> resultSelector) : base(observable, initialState, switchToKeep, switchToIgnore) { _resultSelector = resultSelector; _sectionIndex = initialState == KeepingState.Ignore ? -1 : 0; }
public static IPushObservable <T> FilterSection <T>(this IPushObservable <T> observable, KeepingState initialState, Func <T, SwitchBehavior> switchToKeep, Func <T, SwitchBehavior> switchToIgnore) { return(new FilterSectionSubject <T>(observable, initialState, switchToKeep, switchToIgnore)); }
protected void SetCurrentState(KeepingState currentState) => CurrentState = currentState;
public static IStream <TIn> SelectSection <TIn>(this IStream <TIn> stream, string name, KeepingState initialState, Func <TIn, SwitchBehavior> switcher) { return(new SelectSectionStreamNode <TIn>(name, new SelectSectionArgs <TIn> { Stream = stream, InitialState = initialState, SwitchToKeep = switcher }).Output); }
public static IStream <TOut> SelectSection <TIn, TOut>(this IStream <TIn> stream, string name, KeepingState initialState, Func <TIn, SwitchBehavior> switchToKeep, Func <TIn, SwitchBehavior> switchToIgnore, Func <TIn, int, TOut> resultSelector) { return(new SelectSectionStreamNode <TIn, TOut>(name, new SelectSectionArgs <TIn, TOut> { Stream = stream, InitialState = initialState, SwitchToKeep = switchToKeep, SwitchToIgnore = switchToIgnore, ResultSelector = resultSelector }).Output); }