33 lines
868 B
C#
33 lines
868 B
C#
|
namespace InnovEnergy.Lib.Utils.Reflection;
|
||
|
|
||
|
public abstract class Member
|
||
|
{
|
||
|
public abstract String Name { get; }
|
||
|
public abstract Type Type { get; }
|
||
|
|
||
|
public abstract Boolean IsPublic { get; }
|
||
|
public abstract Boolean IsPrivate { get; }
|
||
|
public abstract Boolean IsStatic { get; }
|
||
|
|
||
|
public abstract IEnumerable<Attribute> Attributes { get; }
|
||
|
}
|
||
|
|
||
|
|
||
|
public static class Members
|
||
|
{
|
||
|
public static IEnumerable<Member> OfInstance<T>(T instance) where T : notnull
|
||
|
{
|
||
|
return instance.GetMembers();
|
||
|
}
|
||
|
|
||
|
public static IEnumerable<Member> GetMembers<T>(this T instance) where T : notnull
|
||
|
{
|
||
|
var fields = instance.GetFields();
|
||
|
var props = instance.GetProperties();
|
||
|
var methods = instance.GetMethods();
|
||
|
|
||
|
return fields
|
||
|
.Concat<Member>(props)
|
||
|
.Concat(methods);
|
||
|
}
|
||
|
}
|