public List <ModelStateError> GetModelErrors(ModelStateDictionary modelState) { var errors = new List <ModelStateError>(); foreach (string key in modelState.Keys) { var field = _fieldNameResolver.GetFieldName(key); errors.AddRange(GetMessages(field, modelState[key].Errors)); errors.AddRange(GetExceptions(field, modelState[key].Errors)); } return(errors); }
public override void Visit(PropertyInfo property, ShapeWalkInfo walkInfo) { var value = walkInfo.Object.GetPropertyValue(property.Name); if (value != null && property.PropertyType.IsDetailOfRawGeneric(walkInfo.GenericDefinition)) { if (property.PropertyType.IsListOfRawGeneric(walkInfo.GenericDefinition)) { value = (value as IEnumerable <object>).Select(p => NextWalk(p, walkInfo)); } else { value = NextWalk(value, walkInfo); } } ((IDictionary <string, object>)_object)[_fieldNameResolver.GetFieldName(property.Name)] = value; }