public IActionResult GetModelProperties(string type, XioOperationType operation) { var t = getModelType(type, operation); List <UIProperty> properties = new List <UIProperty>(); foreach (var prop in t.GetProperties()) { var dn = prop.GetCustomAttribute <DisplayNameAttribute>()?.DisplayName; var required = prop.GetCustomAttribute <RequiredAttribute>() != null; var editor = prop.GetCustomAttribute <XioEditorAttribute>()?.Editor ?? prop.PropertyType.Name; var defValue = prop.GetCustomAttribute <DefaultValueAttribute>()?.Value; var hideUnless = prop.GetCustomAttribute <HideUnlessAttribute>()?.Options; var p = new UIProperty { PropertyName = prop.Name, DisplayName = dn ?? prop.Name, Editor = editor, HideUnless = hideUnless, DefaultValue = defValue, IsRequired = required, Validate = false }; properties.Add(p); } return(Json(properties)); }
public Type getModelType(string type, XioOperationType operation) { if (operation == XioOperationType.Create) { var t = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes().Where(y => y.GetCustomAttribute <XioCreateAttribute>() != null && y.GetCustomAttribute <XioCreateAttribute>().TypeName.Equals(type, StringComparison.CurrentCultureIgnoreCase) && y.IsPublic && !y.IsInterface && !y.IsAbstract)).SingleOrDefault(); return(t.GetCustomAttribute <XioCreateAttribute>().Type); } else if (operation == XioOperationType.List) { return(getModelType <XioListAttribute>(type)); } return(findType(type)); }