Created
February 7, 2011 20:11
-
-
Save mindplay-dk/815092 to your computer and use it in GitHub Desktop.
bugfix for code posted at http://jimblackler.net/blog/?p=49
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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