public static void MapValues(IPOCOForm instance, Form form) { foreach (var prop in GetFieldProps(instance).Where(p => p.CanWrite)) { var field = form.Fields.SingleOrDefault(f => f.Name == prop.Name); if (field != null && field.ValueType == prop.PropertyType) { prop.SetValue(instance, field.Value, null); } } }
public static void SetDefaultValues(IPOCOForm instance, Form form) { if (instance is IProvidesDefaultValues defaultValuesProvider) { defaultValuesProvider.SetDefaultValues(); } foreach (var prop in GetFieldProps(instance).Where(p => p.CanRead)) { var field = form.Fields.SingleOrDefault(f => f.Name == prop.Name); if (field != null && field.ValueType == prop.PropertyType) { field.Value = prop.GetValue(instance, null); } } }
private static IEnumerable <PropertyInfo> GetFieldProps(IPOCOForm instance) { return(GetFieldProps(instance.GetType())); }
public POCOFormBuilderRequestContext(IModel model) : base(model) { Instance = (IPOCOForm)ModelInstance.FormData["PocoInstance"]; }