Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bugfix for code posted at http://jimblackler.net/blog/?p=49
/*
bugfix for "DocsByReflection.cs"
http://jimblackler.net/blog/?p=49
Replace broken XMLFromName() method with the following fixed method:
*/
private static XmlElement XMLFromName(Type type, char prefix, string name)
{
string fullName;
if (String.IsNullOrEmpty(name))
{
fullName = prefix + ":" + type.FullName;
}
else
{
fullName = prefix + ":" + type.FullName + "." + name;
}
XmlDocument xmlDocument = XMLFromAssembly(type.Assembly);
XmlElement matchedElement = null;
foreach (XmlNode xmlNode in xmlDocument["doc"]["members"])
{
if (!(xmlNode is XmlElement))
continue;
var xmlElement = (XmlElement) xmlNode;
if (!xmlElement.Attributes["name"].Value.Equals(fullName))
continue;
if (matchedElement != null)
{
throw new DocsByReflectionException("Multiple matches to query", null);
}
matchedElement = xmlElement;
}
if (matchedElement == null)
{
throw new DocsByReflectionException("Could not find documentation for specified element", null);
}
return matchedElement;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment