Example #1
0
        public static bool DoesNotHaveApiStyle(this XmlElement element, ApiStyle style)
        {
            string styleString   = style.ToString().ToLowerInvariant();
            string apistylevalue = element.GetAttribute("apistyle");

            return(apistylevalue != styleString || string.IsNullOrWhiteSpace(apistylevalue));
        }
Example #2
0
        public static void RemoveApiStyle(this XmlNode node, ApiStyle style)
        {
            var styleAttribute = node.Attributes["apistyle"];

            if (styleAttribute != null && styleAttribute.Value == style.ToString().ToLowerInvariant())
            {
                node.Attributes.Remove(styleAttribute);
            }
        }
Example #3
0
        public static void RemoveApiStyle(this XmlElement element, ApiStyle style)
        {
            string styleString   = style.ToString().ToLowerInvariant();
            string existingValue = element.GetAttribute("apistyle");

            if (string.IsNullOrWhiteSpace(existingValue) || existingValue == styleString)
            {
                element.RemoveAttribute("apistyle");
            }
        }
Example #4
0
        public static void AddApiStyle(this XmlNode node, ApiStyle style)
        {
            string styleString       = style.ToString().ToLowerInvariant();
            var    existingAttribute = node.Attributes["apistyle"];

            if (existingAttribute == null)
            {
                existingAttribute = node.OwnerDocument.CreateAttribute("apistyle");
                node.Attributes.Append(existingAttribute);
            }
            existingAttribute.Value = styleString;
        }
Example #5
0
        void DropApiStyle(XDocument doc, string path)
        {
            string styleString = styleToDrop.ToString().ToLower();
            var    items       = doc
                                 .Descendants()
                                 .Where(n => n.Attributes()
                                        .Any(a => a.Name.LocalName == "apistyle" && a.Value == styleString))
                                 .ToArray();

            foreach (var element in items)
            {
                element.Remove();
            }

            if (styleToDrop == ApiStyle.Classic && ReplaceNativeTypes)
            {
                RewriteCrefsIfNecessary(doc, path);
            }
        }
Example #6
0
        public static void AddApiStyle(this XmlElement element, ApiStyle style)
        {
            string styleString   = style.ToString().ToLowerInvariant();
            var    existingValue = element.GetAttribute("apistyle");

            if (string.IsNullOrWhiteSpace(existingValue) || existingValue != styleString)
            {
                element.SetAttribute("apistyle", styleString);
            }

            // Propagate the API style up to the membernode if necessary
            if (element.LocalName == "AssemblyInfo" && element.ParentNode != null && element.ParentNode.LocalName == "Member")
            {
                var member = element.ParentNode;
                var unifiedAssemblyNode = member.SelectSingleNode("AssemblyInfo[@apistyle='unified']");
                var classicAssemblyNode = member.SelectSingleNode("AssemblyInfo[not(@apistyle) or @apistyle='classic']");

                var    parentAttribute = element.ParentNode.Attributes["apistyle"];
                Action removeStyle     = () => element.ParentNode.Attributes.Remove(parentAttribute);
                Action propagateStyle  = () =>
                {
                    if (parentAttribute == null)
                    {
                        // if it doesn't have the attribute, then add it
                        parentAttribute       = element.OwnerDocument.CreateAttribute("apistyle");
                        parentAttribute.Value = styleString;
                        element.ParentNode.Attributes.Append(parentAttribute);
                    }
                };

                if ((style == ApiStyle.Classic && unifiedAssemblyNode != null) || (style == ApiStyle.Unified && classicAssemblyNode != null))
                {
                    removeStyle();
                }
                else
                {
                    propagateStyle();
                }
            }
        }
Example #7
0
        public static bool HasApiStyle(this XmlNode node, ApiStyle style)
        {
            var attribute = node.Attributes["apistyle"];

            return(attribute != null && attribute.Value == style.ToString().ToLowerInvariant());
        }
Example #8
0
        public static bool HasApiStyle(this XmlElement element, ApiStyle style)
        {
            string styleString = style.ToString().ToLowerInvariant();

            return(element.GetAttribute("apistyle") == styleString);
        }