Exemplo n.º 1
0
        public async Task GeneratePipeDgmlFile()
        {
            var pipe = await Pipe.Builder <int>()
                       .UseTransform()
                       .Value(num => num.ToString())
                       .UseTransform()
                       .Value(double.Parse)
                       .Build();


            var g = new DgmlGraph <IPipe>();

            pipe.Accept(g);
            g.GetDgmlDocument().Save(Console.Out);
        }
Exemplo n.º 2
0
        public async Task CanVisualizeTrueBranchedPipe()
        {
            var builder = Pipe.Builder <int>()
                          .UseBranch((ctx, i) => i % 2 == 0
                                     , Pipe.Builder <int>().Named("Do even stuff")
                                     , "x % 2 == 0")
                          .UseTransform()
                          .Value(num => num.ToString(), "Convert int to string")
                          .UseConsolePrinter();

            var pipe = await builder.Build();

            var g = new DgmlGraph <object>();

            builder.Accept(g);
            pipe.Accept(g);
            g.GetDgmlDocument().Save(Console.Out);
            // g.SaveDgmlAsTempFileAndOpen();
        }
Exemplo n.º 3
0
        public async Task TestMultipleInputPipesBuilderGraph()
        {
            var builder = Pipe.Builder <int>()
                          .UseTransform()
                          .Value(num => num.ToString(), "Convert int to string")
                          .UseConsolePrinter()
                          .UseTransform()
                          .Value(double.Parse, "Parse string to double")
                          .UseConsolePrinter();

            var pipe = await builder.Build();

            var user = Pipe.Builder <int>().Named("User Input").UseTransform().Builder(builder);
            var api  = Pipe.Builder <int>().Named("API Input").UseTransform().Builder(builder);
            var g    = new DgmlGraph <object>();

            user.Accept(g);
            api.Accept(g);
            (await user.Build()).Accept(g);
            (await api.Build()).Accept(g);
            g.GetDgmlDocument().Save(Console.Out);
            // g.SaveDgmlAsTempFileAndOpen();
        }