예제 #1
0
        private static XmlElement GetMatch(string fullName, string nameSpace, Type someAssemblyType, bool throwError)
        {
            XmlDocument xmlDocument    = DocsService.GetXmlFromAssembly(someAssemblyType.Assembly, throwError);
            XmlElement  matchedElement = null;

            if (xmlDocument != null)
            {
                foreach (XmlNode xmlNode in xmlDocument["doc"]["members"])
                {
                    if (!(xmlNode is XmlElement))
                    {
                        continue;
                    }

                    var xmlElement = (XmlElement)xmlNode;

                    if (xmlElement.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }

                    if (xmlElement.Attributes["name"].Value.Equals(fullName, StringComparison.OrdinalIgnoreCase))
                    {
                        if (matchedElement != null)
                        {
                            throw new DocsByReflectionException("Multiple matches to query", null);
                        }

                        matchedElement = xmlElement;
                    }
                }
            }
            return(matchedElement);
        }
예제 #2
0
        /// <summary>
        /// Obtains the XML Element that describes a reflection element by searching the
        /// members for a member that has a name that describes the element.
        /// </summary>
        /// <param name="type">The type or parent type, used to fetch the assembly</param>
        /// <param name="prefix">The prefix as seen in the name attribute in the documentation XML</param>
        /// <param name="name">Where relevant, the full name qualifier for the element</param>
        /// <param name="throwError">If should throw error when documentation is not found. Default is true.</param>
        /// <returns>The member that has a name that describes the specified reflection element</returns>
        public static XmlElement GetXmlFromName(Type type, char prefix, string name, bool throwError)
        {
            string fullName = GetTypeFullNameForXmlDoc(type);

            if (String.IsNullOrEmpty(name))
            {
                fullName = String.Format(CultureInfo.InvariantCulture, "{0}:{1}", prefix, fullName);
            }
            else
            {
                fullName = String.Format(CultureInfo.InvariantCulture, "{0}:{1}.{2}", prefix, fullName, name);
            }

            XmlDocument xmlDocument    = DocsService.GetXmlFromAssembly(type.Assembly, throwError);
            XmlElement  matchedElement = null;

            if (xmlDocument != null)
            {
                foreach (XmlNode xmlNode in xmlDocument["doc"]["members"])
                {
                    if (!(xmlNode is XmlElement))
                    {
                        continue;
                    }

                    var xmlElement = (XmlElement)xmlNode;

                    if (xmlElement.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }
                    if (xmlElement.Attributes["name"].Value.Equals(fullName, StringComparison.OrdinalIgnoreCase))
                    {
                        if (matchedElement != null)
                        {
                            throw new DocsByReflectionException("Multiple matches to query", null);
                        }

                        matchedElement = xmlElement;
                    }
                }
            }

            if (matchedElement == null && throwError)
            {
                ThrowHelper.ThrowDocNotFound();
            }

            return(matchedElement);
        }
예제 #3
0
        public static XmlElement GetXmlForConstructor(Type type, string fullName, bool throwError)
        {
            XmlDocument xmlDocument    = DocsService.GetXmlFromAssembly(type.Assembly, throwError);
            XmlElement  matchedElement = null;

            if (xmlDocument != null)
            {
                foreach (XmlNode xmlNode in xmlDocument["doc"]["members"])
                {
                    if (!(xmlNode is XmlElement))
                    {
                        continue;
                    }

                    var xmlElement = (XmlElement)xmlNode;

                    if (xmlElement.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }
                    if (xmlElement.Attributes["name"].Value.Equals(fullName, StringComparison.OrdinalIgnoreCase))
                    {
                        if (matchedElement != null)
                        {
                            throw new DocsByReflectionException("Multiple matches to query", null);
                        }

                        matchedElement = xmlElement;
                    }
                }
            }

            if (matchedElement == null && throwError)
            {
                ThrowHelper.ThrowDocNotFound();
            }

            return(matchedElement);
        }