Example #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;
        }
Example #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);
        }
Example #3
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);
        }