Пример #1
0
        /// <summary>
        /// Process the given element, all it's attributes and it's child elements.
        /// </summary>
        /// <returns>True if changes were made, false otherwise</returns>
        private bool Process(XElement element)
        {
            var result = false;

            // Process android:name / class
            var localName = element.Name.LocalName;

            if ((localName == "fragment") || (localName == "view"))
            {
                var nameAttr = element.Attribute(XName.Get("name", AndroidConstants.AndroidNamespace));
                if (nameAttr != null)
                {
                    var typeName = nameAttr.Value;
                    customClassNames.Add(typeName);
                    nameAttr.Value = nameConverter.GetConvertedFullName(typeName);
                    result         = true;
                }
                var classAttr = element.Attribute("class");
                if (classAttr != null)
                {
                    var typeName = classAttr.Value;
                    customClassNames.Add(typeName);
                    classAttr.Value = nameConverter.GetConvertedFullName(typeName);
                    result          = true;
                }
            }
            else
            {
                customClassNames.Add(localName);
            }

            // Process custom element names
            if (localName.StartsWith(nameConverter.RootNamespaceDot))
            {
                // Class name used as element name
                element.Name = nameConverter.GetConvertedFullName(localName);
                result       = true;
            }

            // Process child elements
            foreach (var child in element.Elements())
            {
                result |= Process(child);
            }

            return(result);
        }