ReflectionHelper.cs 546 B

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