public DinazorResult CheckRequiredField(MethodInfo methodInfo, IMethodCallMessage msg) { DinazorResult result = new DinazorResult { Status = ResultStatus.Success }; //try to find required attributes var requiredParameters = methodInfo.GetParameters() .Where( l => l.GetCustomAttributes(false).FirstOrDefault(m => m is RequiredAttribute) != null).ToList(); foreach (var parameterMessage in requiredParameters) { var parameter = msg.GetInArg(parameterMessage.Position); if (parameter == null) { result.Message = parameterMessage.Name; return(result); } if (parameter.GetType().IsPrimitive) { continue; } Type type = parameter.GetType(); var requiredSubParameters = type.GetProperties().Where(l => l.GetCustomAttributes(false).FirstOrDefault(z => z.GetType() == typeof(RequiredAttribute)) != null).ToList(); foreach (var propertyInfo in requiredSubParameters) { var value = propertyInfo.GetValue(parameter); if (value == null || value.ToString() == "") { string columnName = propertyInfo.Name; string errorMessage = propertyInfo.GetCustomAttributes(typeof(RequiredAttribute), false).Cast <RequiredAttribute>().Single().ErrorMessage; result.Message = LocaleManager.GetMessage(errorMessage, new string[1] { columnName }); result.Status = ResultStatus.MissingRequiredParamater; _log.Error("Missing Required Parameter : " + columnName); return(result); } } } return(result); }