private static object GetConvertedParameterValue(ParameterInfoWrapper parameter, object value)
        {
            if (!parameter.IsValueRequiredWhenOptionIsPresent)
                value = value != null;

            return Convert.ChangeType(value, parameter.Type);
        }
Esempio n. 2
0
 private static object GetConvertedParameterValue(ParameterInfoWrapper parameter, object value)
 {
     if (!parameter.IsValueRequiredWhenOptionIsPresent)
     {
         value = value != null;
     }
     if (parameter.FromBody)
     {
         var data = JsonConvert.DeserializeObject(
             (string)value,
             parameter.Type
             );
         return(data);
     }
     return(Convert.ChangeType(value, parameter.Type));
 }
Esempio n. 3
0
        private static object GetConvertedParameterValue(ParameterInfoWrapper parameter, object value)
        {
            if (!parameter.IsValueRequiredWhenOptionIsPresent)
            {
                value = value != null;
            }
            if (parameter.FromBody && value is string)
            {
                var data = JsonConvert.DeserializeObject(
                    (string)value,
                    parameter.Type
                    );
                return(data);
            }
            if (parameter.FromBody && value is ExpandoObject)
            {
                var expandoDict = value as IDictionary <string, object>;

                var data = expandoDict.ToObject(parameter.Type);
                return(data);
            }
            return(Convert.ChangeType(value, parameter.Type));
        }