예제 #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;
        }
예제 #2
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);
        }