public FormElement TryBuild(IFormProperty property, Func <string, object> deserializer) { var replacements = property .GetCustomAttributes <ReplaceAttribute>() .OrderBy(attr => attr.Position) .Select(attr => attr.GetReplacement()); return(new ConvertedField( property.Name, property.PropertyType, new ReplacementPipe(Deserializer, replacements))); }
public void Initialize(FormElement element, IFormProperty property, Func <string, object> deserializer) { var attrs = property.GetCustomAttributes <MetaAttribute>(); if (attrs == null) { return; } foreach (var attr in attrs) { if (!string.IsNullOrEmpty(attr.Name)) { element.Metadata[attr.Name] = attr.Value; } } }
public void Initialize(FormElement element, IFormProperty property, Func <string, object> deserializer) { if (!(element is DataFormField dataField)) { return; } var attributes = property.GetCustomAttributes <ValueAttribute>().ToArray(); if (attributes.Length == 0) { return; } var modelType = property.DeclaringType; foreach (var attr in attributes) { dataField.Validators.Add(CreateValidator(modelType, dataField.Key, attr, deserializer)); } }