Example #1
0
        public static async Task <PipelineResult <Wrapper <int> > > UseSampleCommandInvoker(IWorkspace workspace, Command command, string[] origin, string input = "", PipelineOperation <string[], Wrapper <int> >?before = null, PipelineOperation <string[], Wrapper <int> >?after = null)
        {
            using MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(input));
            using StreamReader sr = new StreamReader(ms);
            PipelineBuilder <string[], Wrapper <int> > builder = CreatePipelineBuilder(new TestTerminal(), sr, workspace);

            if (before != null)
            {
                _ = builder.Use("before", async context =>
                {
                    _ = await before(context);
                    return(context.IgnoreResult());
                });
            }
            _ = builder.Use("main", async context =>
            {
                Parser parser = CommandLines.CreateDefaultParser(command, context);
                return(await parser.InvokeAsync(context.Origin, context.Services.GetConsole()));
            });
            if (after != null)
            {
                _ = builder.Use("after", async context =>
                {
                    _ = await after(context);
                    return(context.IgnoreResult());
                });
            }
            return(await ConsumePipelineBuilder(builder, new Logger(), origin));
        }
 public PipelineStep(PipelineOperation operation, bool isRequired)
 {
     this.Operation  = operation;
     this.IsRequired = isRequired;
 }
 private string GetOperationScript(PipelineOperation operation) =>
 operation switch
 {
Example #4
0
 /// <summary>
 /// 数据管道接收到数据时候的事件处理程序
 /// </summary>
 protected override void Client_ReceiveCompleted(object sender, BufferReceiveEventArgs e)
 {
     recbuffer.Write(e.Buffer, e.Offset, e.Count);
     PipelineOperation.OnMessageComing(this, ref recbuffer, this.OnMessageComing);
 }