Added n -> m relation support

This commit is contained in:
2025-01-17 16:58:36 +01:00
parent e9f686cf19
commit 4f68fc578f
16 changed files with 195 additions and 79 deletions

View File

@@ -1,4 +1,5 @@
using System.Linq.Expressions;
using System.Collections;
using System.Linq.Expressions;
using System.Reflection;
namespace HopFrame.Core.Config;
@@ -12,6 +13,7 @@ public class PropertyConfig(PropertyInfo info, TableConfig table, int nthPropert
public bool Searchable { get; set; } = true;
public PropertyInfo? DisplayedProperty { get; set; }
public Func<object, string>? Formatter { get; set; }
public Func<object, string>? EnumerableFormatter { get; set; }
public Func<string, object>? Parser { get; set; }
public Func<object?, Task<IEnumerable<string>>>? Validator { get; set; }
public bool Editable { get; set; } = true;
@@ -19,6 +21,7 @@ public class PropertyConfig(PropertyInfo info, TableConfig table, int nthPropert
public bool DisplayValue { get; set; } = true;
public bool IsRelation { get; set; }
public bool IsRequired { get; set; }
public bool IsEnumerable { get; set; }
public bool IsListingProperty { get; set; }
public int Order { get; set; } = nthProperty;
}
@@ -57,6 +60,11 @@ public class PropertyConfig<TProp>(PropertyConfig config) {
return this;
}
public PropertyConfig<TProp> FormatEach<TInnerProp>(Func<TInnerProp, string> formatter) {
InnerConfig.EnumerableFormatter = obj => formatter.Invoke((TInnerProp)obj);
return this;
}
public PropertyConfig<TProp> ValueParser(Func<string, TProp> parser) {
InnerConfig.Parser = str => parser.Invoke(str)!;
return this;