Files
HopFrame/src/HopFrame.Core/Config/PropertyConfig.cs
2025-01-15 08:02:23 +01:00

44 lines
1.3 KiB
C#

using System.Linq.Expressions;
using System.Reflection;
namespace HopFrame.Core.Config;
public class PropertyConfig(PropertyInfo info) {
public PropertyInfo Info { get; init; } = info;
public string Name { get; set; } = info.Name;
public bool List { get; set; } = true;
public bool Sortable { get; set; } = true;
public bool Searchable { get; set; } = true;
public PropertyInfo? DisplayedProperty { get; set; }
}
public class PropertyConfig<TProp>(PropertyConfig config) {
public PropertyConfig<TProp> SetDisplayName(string displayName) {
config.Name = displayName;
return this;
}
public PropertyConfig<TProp> List(bool display) {
config.List = display;
config.Searchable = false;
return this;
}
public PropertyConfig<TProp> Sortable(bool sortable) {
config.Sortable = sortable;
return this;
}
public PropertyConfig<TProp> Searchable(bool searchable) {
config.Searchable = searchable;
return this;
}
public PropertyConfig<TProp> DisplayedProperty<TInnerProp>(Expression<Func<TProp, TInnerProp>> propertyExpression) {
config.DisplayedProperty = TableConfig<TProp>.GetPropertyInfo(propertyExpression);
return this;
}
}