C#: Basic Reflection Class
Posted
by
Mike
on Stack Overflow
See other posts from Stack Overflow
or by Mike
Published on 2011-02-20T23:23:57Z
Indexed on
2011/02/20
23:24 UTC
Read the original article
Hit count: 179
c#
|reflection
I'm trying to find a basic reflection abstract class that will generate basic information about a class. I have a template of how I would like it to work:
class ThreeList<string,Type,T>
{
string Name {get; set;}
Type Type {get; set;}
T Value {get; set;}
}
abstract class Reflect<T>
{
List<ThreeList<string, Type, T> list;
ReturnType MethodName()
{
foreach (System.Reflection.PropertyInfo prop in this.GetType().GetProperties())
{
object value = prop.GetValue(this, new object[] { });
list.Add(prop.Name, prop.DeclaringType, value);
}
}
}
I'd like it to be infinitely deep, recursively calling Reflect.
Something like this has to exist. I'm not really opposed to coding it myself, I just don't want to go through the hassle if its already been done.
© Stack Overflow or respective owner