Ejemplo n.º 1
0
        public void InstanceUsage()
        {
            RoslynCompiler compiler = new RoslynCompiler();
            var            instance = compiler.Instance();

            //code extension
            instance
            .match <InstanceFoo>()
            .input(new InstanceConnector {
                Id = "input"
            }, dt: FooInput)
            .output(new InstanceConnector {
                Id = "output"
            })
            .then(TransformFoo)
            .match <InstanceBar>()
            .input(new InstanceConnector {
                Id = "input"
            })
            .output(new InstanceConnector {
                Id = "output"
            }, transform:  BarOutput)
            .then(TransformBar)

            .then(TransformInstances);

            SyntaxTree             tree;
            string                 text;
            RoslynInstanceDocument doc = new RoslynInstanceDocument(InstanceTestParser);

            tree = compiler.CompileInstance(doc, out text);
            Assert.IsTrue(tree
                          .GetRoot()
                          .DescendantNodes()
                          .OfType <ParenthesizedLambdaExpressionSyntax>()
                          .Count() == 2); //must have added a PropertyChanged handler
        }
Ejemplo n.º 2
0
        public void InstanceUsage()
        {
            RoslynCompiler compiler = new RoslynCompiler();
            var instance = compiler.Instance();

            SyntaxTree tree;
            string text;

            //code extension
            instance
                .match<InstanceFoo>()
                    .input (new InstanceConnector { Id = "input" }, dt: FooInput)
                    .output(new InstanceConnector { Id = "output" })
                    .then(TransformFoo)
                .match<InstanceBar>()
                    .input(new InstanceConnector { Id = "input" })
                    .output(new InstanceConnector { Id = "output" }, transform:  BarOutput)
                    .then(TransformBar)

                .then(TransformInstances);

            RoslynInstanceDocument doc = new RoslynInstanceDocument(InstanceTestParser);
            tree = compiler.CompileInstance(doc, out text);
            Assert.IsTrue(tree
                .GetRoot()
                .DescendantNodes()
                .OfType<ParenthesizedLambdaExpressionSyntax>()
                .Count() == 1); //must have added a PropertyChanged handler
        }