public void Parser_loads_namespaces()
        {
            var styleSheet = CssParser.Parse(test1);

            Assert.AreEqual(4, styleSheet.Namespaces.Count());

            Assert.AreEqual("", styleSheet.Namespaces[0].Alias);
            Assert.AreEqual(TestNode.GetAssemblyQualifiedNamespaceName(typeof(TestNode)), styleSheet.Namespaces[0].Namespace);

            Assert.AreEqual("xamlcss", styleSheet.Namespaces[1].Alias);
            Assert.AreEqual(TestNode.GetAssemblyQualifiedNamespaceName(typeof(CssNamespace)), styleSheet.Namespaces[1].Namespace);

            Assert.AreEqual("ui", styleSheet.Namespaces[2].Alias);
            Assert.AreEqual(TestNode.GetAssemblyQualifiedNamespaceName(typeof(TestNode)), styleSheet.Namespaces[2].Namespace);

            Assert.AreEqual("special", styleSheet.Namespaces[3].Alias);
            Assert.AreEqual(TestNode.GetAssemblyQualifiedNamespaceName(typeof(TestNode)), styleSheet.Namespaces[3].Namespace);
        }
Exemple #2
0
        public TestNode(UIElement dependencyObject, IDomElement <UIElement, PropertyInfo> parent, string tagname, IEnumerable <IDomElement <UIElement, PropertyInfo> > children = null,
                        IDictionary <string, PropertyInfo> attributes = null, string id = null, string @class = null)
            : base(dependencyObject ?? new UIElement(), parent, parent, TestTreeNodeProvider.Instance)
        {
            this.childNodes = this.logicalChildNodes = children?.ToList() ?? new List <IDomElement <UIElement, PropertyInfo> >();
            foreach (TestNode c in ChildNodes)
            {
                c.parent        = this;
                c.logicalParent = this;
            }

            dependencyObject.Children = this.ChildNodes.Select(x => x.Element).ToList();

            this.classList = new HashSet <string>();
            foreach (var item in (@class ?? "").Split(classSplitter, StringSplitOptions.RemoveEmptyEntries))
            {
                this.ClassList.Add(item);
            }

            this.Id = id;
            var namespaceSeparatorIndex = tagname.IndexOf('|');

            if (namespaceSeparatorIndex > -1)
            {
                this.TagName = tagname.Substring(namespaceSeparatorIndex + 1);
                this.assemblyQualifiedNamespaceName = TestNode.GetAssemblyQualifiedNamespaceName(GetType());
            }
            else
            {
                this.TagName = tagname;
                this.assemblyQualifiedNamespaceName = TestNode.GetAssemblyQualifiedNamespaceName(GetType());
            }

            this.attributes = attributes ?? new Dictionary <string, PropertyInfo>();

            this.StyleInfo = new StyleUpdateInfo
            {
                MatchedType = dependencyObject.GetType()
            };
        }