Skip to content

Instantly share code, notes, and snippets.

@mindplay-dk
Created February 8, 2011 14:18
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/816498 to your computer and use it in GitHub Desktop.
Save mindplay-dk/816498 to your computer and use it in GitHub Desktop.
// Extension for System.Type enabling direct access to <summary> contents.
//
// This extension uses DocsByReflection by Jim Blackler:
//
// http://jimblackler.net/blog/?p=49
//
// (this just does the summary for types, but it should be easy to extend this
// concept to include other members and other tags...)
static class DocsByReflectionExtensions
{
/// <summary>
/// Gets the summary from the &lt;summary&gt; tag in documentation comments of the given Type.
/// </summary>
public static string GetSummary(this System.Type type)
{
XmlElement xml = DocsByReflection.XMLFromType(type);
var summary = xml["summary"];
return summary != null ? summary.InnerText.Trim() : type.Name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment