Beispiel #1
0
        /// <summary>
        /// Create an element descriptor for the given element.
        /// </summary>
        private static ElementDescriptor CreateElementDescriptor(AttrsXmlParser parser, LayoutXmlParser layoutParser, LayoutElement element)
        {
            var result = new ElementDescriptor(element.Name);
            while (element != null)
            {
                // Get attributes for this element
                var attrs = parser.FindElementDescriptor(element.Name);
                if (attrs != null)
                {
                    foreach (var a in attrs.Attributes)
                    {
                        result.Add(a);
                    }
                }

                // Get super class
                if (string.IsNullOrEmpty(element.SuperClassName))
                    break;
                element = layoutParser.FindElement(element.SuperClassName);
            }

            // Add ViewGroup_Layout
            var extraAttrs = parser.FindElementDescriptor("ViewGroup_Layout");
            if (extraAttrs != null)
                result.AddRange(extraAttrs.Attributes);
            // Add ViewGroup_MarginLayout
            extraAttrs = parser.FindElementDescriptor("ViewGroup_MarginLayout");
            if (extraAttrs != null)
                result.AddRange(extraAttrs.Attributes);

            return result;
        }
Beispiel #2
0
        /// <summary>
        /// Create an element descriptor.
        /// </summary>
        private static ElementDescriptor CreateDescriptor(AttrsXmlParser parser, string descriptorName, string shortName)
        {
            var source = parser.FindElementDescriptor(descriptorName);
            var result = new ElementDescriptor(shortName);

            if (source != null)
            {
                result.AddRange(source.Attributes);
            }
            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Default ctor
        /// </summary>
        internal MenuDescriptors(AttrsXmlParser parser)
        {
            menuDescriptor  = CreateDescriptor(parser, "Menu", "menu");
            itemDescriptor  = CreateDescriptor(parser, "MenuItem", "item");
            groupDescriptor = CreateDescriptor(parser, "MenuGroup", "group");

            menuDescriptor.Add(itemDescriptor);
            menuDescriptor.Add(groupDescriptor);
            itemDescriptor.Add(menuDescriptor);
            groupDescriptor.Add(itemDescriptor);
        }
Beispiel #4
0
        /// <summary>
        /// Default ctor
        /// </summary>
        internal LayoutDescriptors(AttrsXmlParser parser, LayoutXmlParser layoutParser)
        {
            viewGroupDescriptors = layoutParser.ViewGroupElements.Where(x => !x.IsAbstract).Select(x => CreateElementDescriptor(parser, layoutParser, x)).ToList();
            var viewDescriptors = layoutParser.ViewElements.Where(x => !x.IsAbstract).Select(x => CreateElementDescriptor(parser, layoutParser, x)).ToList();

            // Add all to viewGroup child lists
            foreach (var viewGroupDescr in viewGroupDescriptors)
            {
                viewGroupDescr.AddRange(viewGroupDescriptors);
                viewGroupDescr.AddRange(viewDescriptors);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Default ctor
        /// </summary>
        internal LayoutDescriptors(AttrsXmlParser parser, LayoutXmlParser layoutParser)
        {
            viewGroupDescriptors = layoutParser.ViewGroupElements.Where(x => !x.IsAbstract).Select(x => CreateElementDescriptor(parser, layoutParser, x)).ToList();
            var viewDescriptors = layoutParser.ViewElements.Where(x => !x.IsAbstract).Select(x => CreateElementDescriptor(parser, layoutParser, x)).ToList();

            // Add all to viewGroup child lists
            foreach (var viewGroupDescr in viewGroupDescriptors)
            {
                viewGroupDescr.AddRange(viewGroupDescriptors);
                viewGroupDescr.AddRange(viewDescriptors);
            }
        }
        /// <summary>
        /// Default ctor
        /// </summary>
        internal DescriptorProviderSet(AttrsXmlParser parser, LayoutXmlParser layoutParser, Table resources)
        {
            this.parser = parser;
            this.layoutParser = layoutParser;

            if (resources != null)
            {
                var pkg = resources.Packages.FirstOrDefault();
                var typeSpec = (pkg != null) ? pkg.TypeSpecs.FirstOrDefault(x => x.Name == "attr") : null;
                parser.AttrTypeSpec = typeSpec;
            }
        }
        /// <summary>
        /// Default ctor
        /// </summary>
        internal DescriptorProviderSet(AttrsXmlParser parser, LayoutXmlParser layoutParser, Table resources)
        {
            this.parser       = parser;
            this.layoutParser = layoutParser;

            if (resources != null)
            {
                var pkg      = resources.Packages.FirstOrDefault();
                var typeSpec = (pkg != null) ? pkg.TypeSpecs.FirstOrDefault(x => x.Name == "attr") : null;
                parser.AttrTypeSpec = typeSpec;
            }
        }
Beispiel #8
0
        /// <summary>
        /// Create an element descriptor for the given element.
        /// </summary>
        private static ElementDescriptor CreateElementDescriptor(AttrsXmlParser parser, LayoutXmlParser layoutParser, LayoutElement element)
        {
            var result = new ElementDescriptor(element.Name);

            while (element != null)
            {
                // Get attributes for this element
                var attrs = parser.FindElementDescriptor(element.Name);
                if (attrs != null)
                {
                    foreach (var a in attrs.Attributes)
                    {
                        result.Add(a);
                    }
                }

                // Get super class
                if (string.IsNullOrEmpty(element.SuperClassName))
                {
                    break;
                }
                element = layoutParser.FindElement(element.SuperClassName);
            }

            // Add ViewGroup_Layout
            var extraAttrs = parser.FindElementDescriptor("ViewGroup_Layout");

            if (extraAttrs != null)
            {
                result.AddRange(extraAttrs.Attributes);
            }
            // Add ViewGroup_MarginLayout
            extraAttrs = parser.FindElementDescriptor("ViewGroup_MarginLayout");
            if (extraAttrs != null)
            {
                result.AddRange(extraAttrs.Attributes);
            }

            return(result);
        }