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

26 lines
726 B
C#

namespace InnovEnergy.Lib.Utils.Reflection;
public abstract class DataMember : Member
{
public abstract Object? Get();
public abstract void Set(Object value);
public abstract Boolean IsWriteable { get; }
public abstract Boolean IsReadable { get; }
}
public static class DataMembers
{
public static IEnumerable<DataMember> OfInstance<T>(T instance) where T : notnull
{
return instance.GetDataMembers();
}
public static IEnumerable<DataMember> GetDataMembers<T>(this T instance) where T : notnull
{
var fields = instance.GetFields();
var props = instance.GetProperties();
return fields.Concat<DataMember>(props);
}
}