Innovenergy_trunk/csharp/Lib/Utils/Reflection/Member.cs

33 lines
868 B
C#
Raw Normal View History

2023-04-05 15:43:27 +00:00
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);
}
}