Reputation: 9527
Is there a way to retrieve metadata about the .NET APIs?
For example, suppose I'd like to get a list of all the properties defined for System.Windows.Documents.List
. It'd be nice to get this information in some structured format such as XML, JSON, etc. Each entry should look something like:
<property name="MarkerStyle" type="TextMarkerStyle" get="true" set="true"/>
I'd like to avoid having to screen scrape the MSDN library. :-)
Upvotes: 2
Views: 105
Reputation: 9527
Thanks to Darin and Robert for the pointers to the System.Reflection
namespace.
Here is a short program which prints out all the public properties of List
:
using System;
using System.Reflection;
using System.Windows.Documents;
namespace ReflectionWpfListPropertiesTest
{
class Program
{
static void Main(string[] args)
{
var members = typeof(List).GetMembers();
Array.ForEach(members, info =>
{
if (info.MemberType == MemberTypes.Property)
Console.WriteLine(info);
});
}
}
}
Upvotes: 1
Reputation: 7748
You can use Reflection and write some code to do the formatting into XML, JSON etc.
Or you can use a tool like Reflector
Upvotes: 1
Reputation: 1039318
You could use Reflection to retrieve metadata about existing classes at runtime. The GetProperties method is something you could start with.
Upvotes: 5