Skip to content

Instantly share code, notes, and snippets.

@mindplay-dk
Created February 7, 2011 20:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindplay-dk/815092 to your computer and use it in GitHub Desktop.
Save mindplay-dk/815092 to your computer and use it in GitHub Desktop.
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