Exemple #1
0
            public Logic(LastOrDefault <TIn> stage) : base(stage.Shape)
            {
                _inlet = stage._in;

                Action onPush = () =>
                {
                    _prev            = Grab(_inlet);
                    _foundAtLeastOne = true;
                    Pull(_inlet);
                };

                Action onUpstreamFinish = () =>
                {
                    if (stage._throwOnDefault && !_foundAtLeastOne)
                    {
                        _promise.TrySetException(new NoSuchElementException("Last of empty stream"));
                    }
                    else
                    {
                        _promise.TrySetResult(_prev);
                    }

                    CompleteStage();
                };

                Action <Exception> onUpstreamFailure = e =>
                {
                    _promise.TrySetException(e);
                    FailStage(e);
                };

                SetHandler(stage._in, onPush, onUpstreamFinish, onUpstreamFailure);
            }
Exemple #2
0
            private void InitInternalSource(Sink <TIn, TMat> sink, TIn firstElement)
            {
                var sourceOut = new SubSource(this, firstElement);

                _completion.TrySetResult(Source.FromGraph(sourceOut.Source)
                                         .RunWith(sink, Interpreter.SubFusingMaterializer));
            }
 public void OnNext(TIn value)
 {
     if (_token.IsCancellationRequested)
     {
         return;
     }
     Queue(QueueType.Data, _transformNext(value, _token), default);
 }
Exemple #4
0
            private void InitInternalSource(Sink <TIn, TMat> sink, TIn firstElement)
            {
                var sourceOut = new SubSource(this, firstElement);

                try {
                    var matVal = Source.FromGraph(sourceOut.Source)
                                 .RunWith(sink, Interpreter.SubFusingMaterializer);
                    _completion.TrySetResult(matVal);
                }
                catch (Exception ex)
                {
                    _completion.TrySetException(ex);
                    FailStage(ex);
                }
            }
Exemple #5
0
 public override Task <CoroutineState> Send(TIn value)
 {
     if (!used)
     {
         used = true;
         TaskCompletionSource <CoroutineState> k2 = new TaskCompletionSource <CoroutineState>();
         k.SetResult(new SendMessage()
         {
             value = value, exception = null, k = k2
         });
         return(k2.Task);
     }
     else
     {
         throw new InvalidOperationException("A result has already been sent to this coroutine state");
     }
 }
Exemple #6
0
            public async Task <TOut> ExecuteAsync(TIn input, TOption option)
            {
                if (this.isDisposed)
                {
                    throw new ObjectDisposedException(this.ToString());
                }

                string inputString  = Helper.Serilize(input);
                string optionString = Helper.Serilize(option);

                var inputs = new ValueSet();

                inputs.Add(AbstractPlugin <object, object, object> .START_KEY, inputString);
                inputs.Add(AbstractPlugin <object, object, object> .OPTION_KEY, optionString);
                inputs.Add(AbstractPlugin <object, object, object> .ID_KEY, this.id);

                var response = await this.connection.SendMessageAsync(inputs);

                if (response.Status != AppServiceResponseStatus.Success)
                {
                    throw new Exceptions.ConnectionFailureException(response.Status);
                }
                if (response.Message.ContainsKey(AbstractPlugin <object, object, object> .ERROR_KEY))
                {
                    throw new Exceptions.PluginException(response.Message[AbstractPlugin <object, object, object> .ERROR_KEY] as string);
                }
                if (!response.Message.ContainsKey(AbstractPlugin <object, object, object> .RESULT_KEY))
                {
                    return(default(TOut));
                }
                var outputString = response.Message[AbstractPlugin <object, object, object> .RESULT_KEY] as string;

                if (String.IsNullOrWhiteSpace(outputString))
                {
                    return(default(TOut));
                }

                var output = Helper.DeSerilize <TOut>(outputString);

                return(output);
            }
 public abstract void Execute(TIn input);
 public abstract TOut Execute(TIn input);
Exemple #9
0
 public abstract Task <CoroutineState> Send(TIn value);
 public Message(TIn inpart, TOut outpart)
 {
     this.input  = inpart;
     this.output = outpart;
 }
Exemple #11
0
 public async Task <TOut> ExecuteAsync(TIn input, IProgress <TProgress> progress = null, CancellationToken cancelTokem = default(CancellationToken))
 {
     using (var plugin = await GetPluginConnection(progress, cancelTokem))
         return(await plugin.ExecuteAsync(input));
 }
 public TOut EvalWith(TIn value)
 {
     return(WorkflowInvoker.Invoke(this, new Dictionary <string, object> {
         { "Value", value }
     }));
 }
Exemple #13
0
 public static async Task <(TIn, TOut)> CallWithArgs <TIn, TOut>(this IPayloadV2Client src,
                                                                 MethodInfo <TIn, TOut> method, TIn args,
                                                                 CancellationToken cancel = default, int attempt = 3,
                                                                 Action <double> progress = null)
Exemple #14
0
 public override void OnPush()
 {
     _prev            = Grab(_stage._in);
     _foundAtLeastOne = true;
     Pull(_stage._in);
 }
Exemple #15
0
 public BitwiseCaster(TIn input)
 {
     Output = default(TOut);
     // Must be initialized after output, otherwise memory is overwritten.
     Input = input;
 }
Exemple #16
0
 public TOut Get(TIn parameter) => _select.Get(parameter);
Exemple #17
0
 public TOut ProcessRow(TIn value) => _process(value, _context);