ReflectionHelper.cs 572 B

12345678910111213141516171819
  1. using System.Reflection;
  2. namespace Universal;
  3. public class Property(string name, Type type, object? value)
  4. {
  5. public string Name { get; } = name;
  6. public Type TypeName { get; } = type;
  7. public object Value { get; } = value ??= "NULL";
  8. }
  9. public class ReflectionHelper
  10. {
  11. public static IEnumerable<Property> FromatDitits<T>(T model) where T : notnull
  12. {
  13. foreach (PropertyInfo propertyInfo in model.GetType().GetRuntimeProperties())
  14. yield return new(propertyInfo.Name, propertyInfo.PropertyType, propertyInfo.GetValue(model));
  15. }
  16. }