Beispiel #1
0
        public void CheckWrongNamespaceTest()
        {
            var root = new RootObjectNode("Window");
            var st = new SyntaxTree(new List<string> { "System.Windows.Forms" }, root, new List<ObjectNode> { root });

            analyzer.Analyze(st);
        }
Beispiel #2
0
        private void Root()
        {
            var token = GetToken();
            if (!(token is TypeToken))
                // todo: error message
                throw new EdgeParserException();

            var type = ((TypeToken)token).Type;

            objects["this"] = null;

            if (CheckSymbol(PeekToken(), '#'))
                // todo: error message
                throw new EdgeParserException();

            var ctor = CtorArgs();
            var properties = Properties();

            var obj = new RootObjectNode(type, ctor, properties);
            objects["this"] = obj;
        }
Beispiel #3
0
        public void WindowResourceTest()
        {
            var tokens = new List<IToken>
            {
                new TypeToken("Window"),
                new SymbolToken('{'),
                new PropertyToken("Resources"),
                new SymbolToken(':'),
                new SymbolToken('['),
                new TypeToken("Style"),
                new SymbolToken('#'),
                new IdToken("baseStyle"),
                new SymbolToken(','),
                new TypeToken("Brush"),
                new SymbolToken('#'),
                new IdToken("newBrush"),
                new SymbolToken(']'),
                new SymbolToken('}')
            };

            var root = new RootObjectNode(
                "Window",
                new List<PropertyNode>
                {
                    new PropertyNode(
                        "Resources",
                        new ArrayNode(
                            null,
                            new IValueNode[]
                            {
                                new ReferenceNode("baseStyle", "Style"),
                                new ReferenceNode("newBrush", "Brush")
                            }))
                });

            Test(tokens, new SyntaxTree(parser.Namespaces, root,
                new List<ObjectNode>
                {
                    new ObjectNode("Style", "baseStyle"),
                    new ObjectNode("Brush", "newBrush"),
                    root
                }));
        }
Beispiel #4
0
        public void PropertyObjectWithoutPropertiesTest()
        {
            var tokens = new List<IToken>
            {
                new TypeToken("Window"),
                new SymbolToken('{'),
                new PropertyToken("Content"),
                new SymbolToken(':'),
                new TypeToken("Grid"),
                new SymbolToken('('),
                new SymbolToken(')'),
                new SymbolToken('}')
            };

            var root = new RootObjectNode(
                "Window",
                new List<PropertyNode>
                {
                    new PropertyNode("Content", new ReferenceNode("grid1","Grid"))
                });

            Test(tokens, new SyntaxTree(parser.Namespaces, root,
                new List<ObjectNode>
                {
                    root,
                    new ObjectNode("Grid", "grid1")
                }));
        }
Beispiel #5
0
        public void ShortBindingOnlyPathTest()
        {
            var tokens = new List<IToken>
            {
                new TypeToken("Window"),
                new SymbolToken('{'),
                new PropertyToken("Title"),
                new SymbolToken(':'),
                new SymbolToken('@'),
                new WordToken("WindowState"),
                new SymbolToken('}')
            };

            var root = new RootObjectNode(
                "Window",
                new List<PropertyNode>
                {
                    new PropertyNode("Title", new BindingNode("WindowState"))
                });

            Test(tokens, new SyntaxTree(parser.Namespaces, root,
                new List<ObjectNode>
                {
                    root
                }));
        }
Beispiel #6
0
        public void ArrayTest()
        {
            var tokens = new List<IToken>
            {
                new TypeToken("Window"),
                new SymbolToken('{'),
                new PropertyToken("Content"),
                new SymbolToken(':'),
                new TypeToken("TextBox"),
                new SymbolToken('['),
                new TypeToken("TextBox"),
                new SymbolToken('('),
                new SymbolToken(')'),
                new SymbolToken(','),
                new TypeToken("TextBox"),
                new SymbolToken('('),
                new SymbolToken(')'),
                new SymbolToken(']'),
                new SymbolToken('}')
            };

            var root = new RootObjectNode(
                "Window",
                new List<PropertyNode>
                {
                    new PropertyNode(
                        "Content",
                        new ArrayNode(
                            "TextBox",
                            new IValueNode[]
                            {
                                new ReferenceNode("textBox1", "TextBox"),
                                new ReferenceNode("textBox2", "TextBox")
                            }))
                });

            Test(tokens, new SyntaxTree(parser.Namespaces, root,
                new List<ObjectNode>
                {
                    root,
                    new ObjectNode("TextBox", "textBox1"),
                    new ObjectNode("TextBox", "textBox2")
                }));
        }
Beispiel #7
0
        public void ObjectWithStringPropertyTest()
        {
            var tokens = new List<IToken>
            {
                new TypeToken("Window"),
                new SymbolToken('{'),
                new PropertyToken("Title"),
                new SymbolToken(':'),
                new StringToken("Hello"),
                new SymbolToken('}')
            };

            var root = new RootObjectNode(
                "Window",
                new List<PropertyNode>
                {
                    new PropertyNode("Title", new StringNode("Hello"))
                });

            Test(tokens, new SyntaxTree(parser.Namespaces, root, new List<ObjectNode> { root }));
        }
Beispiel #8
0
        public void ObjectWithIdPropertyTest()
        {
            var tokens = new List<IToken>
            {
                new TypeToken("Window"),
                new SymbolToken('{'),
                new PropertyToken("Icon"),
                new SymbolToken(':'),
                new TypeToken("BitmapImage"),
                new SymbolToken('#'),
                new IdToken("bitmap"),
                new SymbolToken(','),
                new PropertyToken("Content"),
                new SymbolToken(':'),
                new SymbolToken('#'),
                new IdToken("bitmap"),
                new SymbolToken('}')
            };

            var root = new RootObjectNode(
                "Window",
                new List<PropertyNode>
                {
                    new PropertyNode("Icon", new ReferenceNode("bitmap","BitmapImage")),
                    new PropertyNode("Content", new ReferenceNode("bitmap","BitmapImage"))
                });

            Test(tokens, new SyntaxTree(parser.Namespaces, root,
                new List<ObjectNode>
                {
                    new ObjectNode("BitmapImage", "bitmap"),
                    root
                }));
        }
Beispiel #9
0
 public void ObjectWithNumberPropertyTest()
 {
     var root = new RootObjectNode("Window",
                                   new List<PropertyNode>
                                   {
                                       new PropertyNode("Width", new NumberNode(1024.6))
                                   });
     Test(new List<IToken>
     {
         new TypeToken("Window"),
         new SymbolToken('{'),
         new PropertyToken("Width"),
         new SymbolToken(':'),
         new NumberToken(1024.6),
         new SymbolToken('}')
     },
     new SyntaxTree(parser.Namespaces, root, new List<ObjectNode> { root }));
 }
Beispiel #10
0
        public void ObjectWithFullNameEnumPropertyTest()
        {
            var tokens = new List<IToken>
            {
                new TypeToken("Window"),
                new SymbolToken('{'),
                new PropertyToken("WindowState"),
                new SymbolToken(':'),
                new WordToken("WindowState"),
                new SymbolToken('.'),
                new WordToken("Maximized"),
                new SymbolToken('}')
            };

            var root = new RootObjectNode(
                "Window",
                new List<PropertyNode>
                {
                    new PropertyNode("WindowState", new EnumNode("WindowState", "Maximized"))
                });

            Test(tokens, new SyntaxTree(parser.Namespaces, root,
                new List<ObjectNode>
                {
                    root
                }));
        }
Beispiel #11
0
        public void ObjectCtorTest()
        {
            var tokens = new List<IToken>
            {
                new TypeToken("Window"),
                new SymbolToken('{'),
                new PropertyToken("Icon"),
                new SymbolToken(':'),
                new TypeToken("BitmapImage"),
                new SymbolToken('('),
                new TypeToken("Uri"),
                new SymbolToken('('),
                new StringToken("Icon.ico"),
                new SymbolToken(')'),
                new SymbolToken(')'),
                new SymbolToken('}')
            };

            var root = new RootObjectNode(
                "Window",
                new List<PropertyNode>
                {
                    new PropertyNode("Icon", new ReferenceNode("bitmapImage1","BitmapImage"))
                });

            Test(tokens, new SyntaxTree(parser.Namespaces, root,
                new List<ObjectNode>
                {
                    root,
                    new ObjectNode(
                        "BitmapImage",
                        "bitmapImage1",
                        new List<IValueNode>
                        {
                            new ReferenceNode("uri1","Uri")
                        }),
                    new ObjectNode(
                        "Uri",
                        "uri1",
                        new List<IValueNode>
                        {
                            new StringNode("Icon.ico")
                        })
                }));
        }
Beispiel #12
0
        public void NamespaceWithObjectTest()
        {
            var tokens = new List<IToken>
            {
                new UsingToken(),
                new WordToken("System"),
                new SymbolToken(';'),
                new UsingToken(),
                new WordToken("System.Windows"),
                new SymbolToken(';'),
                new TypeToken("Window"),
                new SymbolToken('{'),
                new SymbolToken('}')
            };

            var namespaces = parser.Namespaces.Union(new List<string>
            {
                "System",
                "System.Windows"
            });
            var root = new RootObjectNode("Window");
            var objectNodes = new List<ObjectNode> { root };

            Test(tokens, new SyntaxTree(namespaces, root, objectNodes));
        }
Beispiel #13
0
        public void GridColumnDefinitionsTest()
        {
            var tokens = new List<IToken>
            {
                new TypeToken("Grid"),
                new SymbolToken('{'),
                new PropertyToken("ColumnDefinitions"),
                new SymbolToken(':'),
                new SymbolToken('['),
                new TypeToken("ColumnDefinition"),
                new SymbolToken('('),
                new SymbolToken(')'),
                new SymbolToken(','),
                new TypeToken("ColumnDefinition"),
                new SymbolToken('('),
                new SymbolToken(')'),
                new SymbolToken(']'),
                new SymbolToken('}')
            };

            var root = new RootObjectNode(
                "Grid",
                new List<PropertyNode>
                {
                    new PropertyNode(
                        "ColumnDefinitions",
                        new ArrayNode(
                            null,
                            new IValueNode[]
                            {
                                new ReferenceNode("columnDefinition1", "ColumnDefinition"),
                                new ReferenceNode("columnDefinition2", "ColumnDefinition")
                            }))
                });

            Test(tokens, new SyntaxTree(parser.Namespaces, root,
                new List<ObjectNode>
                {
                    root,
                    new ObjectNode("ColumnDefinition","columnDefinition1"),
                    new ObjectNode("ColumnDefinition","columnDefinition2")
                }));
        }
Beispiel #14
0
        public void BindingShortTest()
        {
            var tokens = new List<IToken>
            {
                new TypeToken("Window"),
                new SymbolToken('{'),
                new PropertyToken("Title"),
                new SymbolToken(':'),
                new SymbolToken('@'),
                new WordToken("tb.Text"),
                new SymbolToken(','),
                new PropertyToken("Content"),
                new SymbolToken(':'),
                new TypeToken("TextBox"),
                new SymbolToken('#'),
                new IdToken("tb"),
                new SymbolToken('}')
            };

            var root = new RootObjectNode(
                "Window",
                new List<PropertyNode>
                {
                    new PropertyNode("Title", new BindingNode("tb", "Text")),
                    new PropertyNode("Content", new ReferenceNode("tb","TextBox"))
                });

            Test(tokens, new SyntaxTree(parser.Namespaces, root,
                new List<ObjectNode>
                {
                    new ObjectNode("TextBox", "tb"),
                    root
                }));
        }