internal static bool IsDescendant <T>(StormToken token, IStorm <T> root, Action <StormToken, EStormVisitType>?rootOnVisit, IStormNode otherNode) { if (otherNode == root) { return(true); } if (otherNode is IStormSocket <T> socket && socket.Target == root) { return(true); } if (rootOnVisit == null) { return(false); } var hasEntered = false; void TargetOnVisit(StormToken enteredToken, EStormVisitType visitType) { hasEntered |= Equals(enteredToken, token) && visitType == EStormVisitType.EnterLoopSearch; } otherNode.OnVisit += TargetOnVisit; rootOnVisit.Invoke(token, EStormVisitType.EnterLoopSearch); rootOnVisit.Invoke(token, EStormVisitType.LeaveLoopSearch); otherNode.OnVisit -= TargetOnVisit; return(hasEntered); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TFourth, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, IStorm <TFourth> fourth, Func <StormFuncInput <TFirst>, StormFuncInput <TSecond>, StormFuncInput <TThird>, StormFuncInput <TFourth>, TResult> func) { if (first == null) { throw new ArgumentNullException(nameof(first)); } if (second == null) { throw new ArgumentNullException(nameof(second)); } if (third == null) { throw new ArgumentNullException(nameof(third)); } if (fourth == null) { throw new ArgumentNullException(nameof(fourth)); } if (func == null) { throw new ArgumentNullException(nameof(func)); } return(new StormFuncFromStates <TFirst, TSecond, TThird, TFourth, TResult>(first, second, third, fourth, func, null)); }
public IStorm <TResult> Create <TFirst, TResult>( IStorm <TFirst> first, Func <TFirst, IStorm <TResult> > func, IEqualityComparer <TResult> comparer) { return(Storm.Func.Create(first, func).SwitchWithCompare(comparer)); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, Func <StormFuncInput <TFirst>, StormFuncInput <TSecond>, StormFuncInput <TThird>, TResult> func) { if (first == null) { throw new ArgumentNullException(nameof(first)); } if (second == null) { throw new ArgumentNullException(nameof(second)); } if (third == null) { throw new ArgumentNullException(nameof(third)); } if (func == null) { throw new ArgumentNullException(nameof(func)); } return(new StormFuncFromStates <TFirst, TSecond, TThird, TResult>(first, second, third, func, EqualityComparer <TResult> .Default)); }
public IStorm <TResult> Create <TFirst, TSecond, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, Func <TFirst, TSecond, IStorm <TResult> > func) { return(Storm.Func.Create(first, second, func).SwitchWithCompare()); }
public IStorm <TResult> Create <TFirst, TSecond, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, Func <StormFuncInput <TFirst>, StormFuncInput <TSecond>, IStorm <TResult> > func) { return(Storm.Func.FromStates.Create(first, second, func).SwitchWithoutCompare()); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TFourth, TFifth, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, IStorm <TFourth> fourth, IStorm <TFifth> fifth, Func <TFirst, TSecond, TThird, TFourth, TFifth, TResult> func) { if (first == null) { throw new ArgumentNullException(nameof(first)); } if (second == null) { throw new ArgumentNullException(nameof(second)); } if (third == null) { throw new ArgumentNullException(nameof(third)); } if (fourth == null) { throw new ArgumentNullException(nameof(fourth)); } if (fifth == null) { throw new ArgumentNullException(nameof(fifth)); } if (func == null) { throw new ArgumentNullException(nameof(func)); } return(new StormFuncFromValues <TFirst, TSecond, TThird, TFourth, TFifth, TResult>(first, second, third, fourth, fifth, func, EqualityComparer <TResult> .Default)); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, Func <TFirst, TSecond, TThird, TResult> func) { if (first == null) { throw new ArgumentNullException(nameof(first)); } if (second == null) { throw new ArgumentNullException(nameof(second)); } if (third == null) { throw new ArgumentNullException(nameof(third)); } if (func == null) { throw new ArgumentNullException(nameof(func)); } return(new StormFuncFromValues <TFirst, TSecond, TThird, TResult>(first, second, third, func, null)); }
public IStorm <TResult> Create <TFirst, TSecond, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, Func <TFirst, TSecond, TResult> func, IEqualityComparer <TResult> comparer) { if (first == null) { throw new ArgumentNullException(nameof(first)); } if (second == null) { throw new ArgumentNullException(nameof(second)); } if (func == null) { throw new ArgumentNullException(nameof(func)); } if (comparer == null) { throw new ArgumentNullException(nameof(comparer)); } return(new StormFuncFromValues <TFirst, TSecond, TResult>(first, second, func, comparer)); }
protected StormFuncBase( IStorm <TFirst> first, IEqualityComparer <TResult> comparer) : base(1, comparer) { First = first; First.OnVisit += FirstOnVisit; }
public StormSwitch(IStorm <IStorm <TResult> > selector, IEqualityComparer <TResult>?comparer) : base(3, comparer) { _selector = selector; UpdateTarget(); _hasTargetChanged = false; _selector.OnVisit += SelectorOnVisit; }
public StormFuncFromValues( IStorm <TFirst> first, Func <TFirst, TResult> func, IEqualityComparer <TResult> comparer) : base(first, comparer) { _func = func; Update(); }
public static IStorm <T> SwitchWithoutCompare <T>(this IStorm <IStorm <T> > selector) { if (selector == null) { throw new ArgumentNullException(nameof(selector)); } return(new StormSwitch <T>(selector, null)); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, Func <TFirst, TSecond, TThird, IStorm <TResult> > func, IEqualityComparer <TResult> comparer) { return(Storm.Func.Create(first, second, third, func).SwitchWithCompare(comparer)); }
public static IStorm <T> SwitchWithCompare <T>(this IStorm <IStorm <T> > selector) { if (selector == null) { throw new ArgumentNullException(nameof(selector)); } return(new StormSwitch <T>(selector, EqualityComparer <T> .Default)); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TFourth, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, IStorm <TFourth> fourth, Func <TFirst, TSecond, TThird, TFourth, IStorm <TResult> > func) { return(Storm.Func.Create(first, second, third, fourth, func).SwitchWithCompare()); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TFourth, TFifth, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, IStorm <TFourth> fourth, IStorm <TFifth> fifth, Func <StormFuncInput <TFirst>, StormFuncInput <TSecond>, StormFuncInput <TThird>, StormFuncInput <TFourth>, StormFuncInput <TFifth>, IStorm <TResult> > func) { return(Storm.Func.FromStates.Create(first, second, third, fourth, fifth, func).SwitchWithoutCompare()); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, IStorm <TFourth> fourth, IStorm <TFifth> fifth, IStorm <TSixth> sixth, IStorm <TSeventh> seventh, IStorm <TEighth> eighth, Func <StormFuncInput <TFirst>, StormFuncInput <TSecond>, StormFuncInput <TThird>, StormFuncInput <TFourth>, StormFuncInput <TFifth>, StormFuncInput <TSixth>, StormFuncInput <TSeventh>, StormFuncInput <TEighth>, TResult> func, IEqualityComparer <TResult> comparer) { if (first == null) { throw new ArgumentNullException(nameof(first)); } if (second == null) { throw new ArgumentNullException(nameof(second)); } if (third == null) { throw new ArgumentNullException(nameof(third)); } if (fourth == null) { throw new ArgumentNullException(nameof(fourth)); } if (fifth == null) { throw new ArgumentNullException(nameof(fifth)); } if (sixth == null) { throw new ArgumentNullException(nameof(sixth)); } if (seventh == null) { throw new ArgumentNullException(nameof(seventh)); } if (eighth == null) { throw new ArgumentNullException(nameof(eighth)); } if (func == null) { throw new ArgumentNullException(nameof(func)); } if (comparer == null) { throw new ArgumentNullException(nameof(comparer)); } return(new StormFuncFromStates <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TResult>(first, second, third, fourth, fifth, sixth, seventh, eighth, func, comparer)); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, IStorm <TFourth> fourth, IStorm <TFifth> fifth, IStorm <TSixth> sixth, IStorm <TSeventh> seventh, IStorm <TEighth> eighth, Func <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, IStorm <TResult> > func) { return(Storm.Func.Create(first, second, third, fourth, fifth, sixth, seventh, eighth, func).SwitchWithoutCompare()); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, IStorm <TFourth> fourth, IStorm <TFifth> fifth, IStorm <TSixth> sixth, IStorm <TSeventh> seventh, Func <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, IStorm <TResult> > func, IEqualityComparer <TResult> comparer) { return(Storm.Func.Create(first, second, third, fourth, fifth, sixth, seventh, func).SwitchWithCompare(comparer)); }
public void SelfConnectIsLoop() { var input = Storm.Input.Create <int>(); IStorm <int> swicht = null; IStorm <int> Selector(int value) { return(value switch { 0 => input, 1 => swicht, _ => null }); }
public static void Connect <T>(this IStormSocket <T> socket, IStorm <T> target) { if (socket == null) { throw new ArgumentNullException(nameof(socket)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } using var tokenSource = Storm.TokenSource.CreateSource(); socket.Connect(tokenSource.Token, target); }
public IStorm <TResult> Create <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TResult>( IStorm <TFirst> first, IStorm <TSecond> second, IStorm <TThird> third, IStorm <TFourth> fourth, IStorm <TFifth> fifth, IStorm <TSixth> sixth, IStorm <TSeventh> seventh, IStorm <TEighth> eighth, Func <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TResult> func) { if (first == null) { throw new ArgumentNullException(nameof(first)); } if (second == null) { throw new ArgumentNullException(nameof(second)); } if (third == null) { throw new ArgumentNullException(nameof(third)); } if (fourth == null) { throw new ArgumentNullException(nameof(fourth)); } if (fifth == null) { throw new ArgumentNullException(nameof(fifth)); } if (sixth == null) { throw new ArgumentNullException(nameof(sixth)); } if (seventh == null) { throw new ArgumentNullException(nameof(seventh)); } if (eighth == null) { throw new ArgumentNullException(nameof(eighth)); } if (func == null) { throw new ArgumentNullException(nameof(func)); } return(new StormFuncFromValues <TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TResult>(first, second, third, fourth, fifth, sixth, seventh, eighth, func, null)); }
public IStorm <TResult> Create <TFirst, TResult>( IStorm <TFirst> first, Func <TFirst, TResult> func) { if (first == null) { throw new ArgumentNullException(nameof(first)); } if (func == null) { throw new ArgumentNullException(nameof(func)); } return(new StormFuncFromValues <TFirst, TResult>(first, func, EqualityComparer <TResult> .Default)); }
public IStorm <TResult> Create <TFirst, TResult>( IStorm <TFirst> first, Func <StormFuncInput <TFirst>, TResult> func) { if (first == null) { throw new ArgumentNullException(nameof(first)); } if (func == null) { throw new ArgumentNullException(nameof(func)); } return(new StormFuncFromStates <TFirst, TResult>(first, func, null)); }
private void UpdateTarget() { _hasTargetChanged = true; if (_target != null) { _target.OnVisit -= TargetOnVisit; } _selector.TryGetValue(out _target); if (_target != null) { if (IsDescendant(_target)) { _target = this; } else { _target.OnVisit += TargetOnVisit; } } }
public int FuncWith1InputWithErrors(IStorm <int> first) {
public void Connect(StormToken token, IStorm <T> target) { if (token.Equals(default))
public IStorm <TResult> Create <TFirst, TResult>( IStorm <TFirst> first, Func <TFirst, IStorm <TResult> > func) { return(Storm.Func.Create(first, func).SwitchWithoutCompare()); }
public IStorm <TResult> Create <TFirst, TResult>( IStorm <TFirst> first, Func <StormFuncInput <TFirst>, IStorm <TResult> > func) { return(Storm.Func.FromStates.Create(first, func).SwitchWithCompare()); }