public Object Validate(Object Value) { if (Type == S4JFieldType.ANY) { return(Value); } if (IsRequired && Value == null) { throw new S4JNullParameterException("Parameter " + Name + " cannot be null"); } if (Value != null && Type == S4JFieldType.BOOL) { if (!MyTypeHelper.IsBoolean(Value.GetType())) { throw new S4JInvalidParameterTypeException("Parameter " + Name + " should be of type boolean"); } } if (Value != null && Type == S4JFieldType.DATETIME) { if (!MyTypeHelper.IsDateTime(Value.GetType())) { throw new S4JInvalidParameterTypeException("Parameter " + Name + " should be of type datetime"); } } if (Value != null && Type == S4JFieldType.FLOAT) { if (!MyTypeHelper.IsNumeric(Value.GetType())) { throw new S4JInvalidParameterTypeException("Parameter " + Name + " should be of type float"); } } if (Value != null && Type == S4JFieldType.INT) { if (!MyTypeHelper.IsInteger(Value.GetType())) { throw new S4JInvalidParameterTypeException("Parameter " + Name + " should be of type integer"); } } if (Value != null && Type == S4JFieldType.STRING) { if (!MyTypeHelper.IsString(Value.GetType())) { throw new S4JInvalidParameterTypeException("Parameter " + Name + " should be of type string"); } } if (Type == S4JFieldType.ARRAY) { if (Value == null) { return(new List <Object>()); } else if (!(Value is IList)) { //if (MyTypeHelper.IsClass(Value.GetType()) || Value is IDictionary<String, Object>) // return new List<Object>() { Value }; throw new S4JInvalidParameterTypeException("Parameter " + Name + " should be of type array"); } } if (Value != null && Type == S4JFieldType.OBJECT) { if (!(MyTypeHelper.IsClass(Value.GetType()) || Value is IDictionary <String, Object>) || Value is IList) { throw new S4JInvalidParameterTypeException("Parameter " + Name + " should be of type object"); } } return(Value); }