コード例 #1
0
ファイル: Stages.cs プロジェクト: supadmins/akka.net
            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);
            }
コード例 #2
0
ファイル: Sinks.cs プロジェクト: ziez/akka.net
            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));
            }
コード例 #3
0
 public void OnNext(TIn value)
 {
     if (_token.IsCancellationRequested)
     {
         return;
     }
     Queue(QueueType.Data, _transformNext(value, _token), default);
 }
コード例 #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);
                }
            }
コード例 #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");
     }
 }
コード例 #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);
            }
コード例 #7
0
 public abstract void Execute(TIn input);
コード例 #8
0
 public abstract TOut Execute(TIn input);
コード例 #9
0
 public abstract Task <CoroutineState> Send(TIn value);
コード例 #10
0
 public Message(TIn inpart, TOut outpart)
 {
     this.input  = inpart;
     this.output = outpart;
 }
コード例 #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));
 }
コード例 #12
0
 public TOut EvalWith(TIn value)
 {
     return(WorkflowInvoker.Invoke(this, new Dictionary <string, object> {
         { "Value", value }
     }));
 }
コード例 #13
0
ファイル: IPayloadV2Client.cs プロジェクト: asvol/mavlink.net
 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)
コード例 #14
0
ファイル: Stages.cs プロジェクト: marcpiechura/akka.net
 public override void OnPush()
 {
     _prev            = Grab(_stage._in);
     _foundAtLeastOne = true;
     Pull(_stage._in);
 }
コード例 #15
0
 public BitwiseCaster(TIn input)
 {
     Output = default(TOut);
     // Must be initialized after output, otherwise memory is overwritten.
     Input = input;
 }
コード例 #16
0
 public TOut Get(TIn parameter) => _select.Get(parameter);
コード例 #17
0
ファイル: Program copy.cs プロジェクト: paillave/Etl.Net
 public TOut ProcessRow(TIn value) => _process(value, _context);