TranslateValue() public method

Get a CLR object of type desiredCLRType from the value graphQLValue.
public TranslateValue ( Value graphQLValue, Type desiredCLRType ) : object
graphQLValue Value
desiredCLRType System.Type
return object
コード例 #1
0
        private static object GetParameter(ParameterInfo param, VariableTypes variableTypes, IEnumerable <ExecArgument <Info> > inputs)
        {
            var input = inputs.FirstOrDefault(i => i.Argument.ArgumentName == param.Name);

            return(input != null
                ? variableTypes.TranslateValue(input.Value, param.ParameterType)
                : GetDefault(param.ParameterType));
        }
コード例 #2
0
        private static object GetParamlessArgs
            (Type argsType, ConstructorInfo paramlessCtor, VariableTypes variableTypes, IEnumerable <ExecArgument <Info> > inputs)
        {
            var args = paramlessCtor.Invoke(null);

            foreach (var input in inputs)
            {
                var prop = argsType.GetProperty(input.Argument.ArgumentName);
                prop.GetSetMethod()
                .Invoke(args, new[]
                {
                    variableTypes.TranslateValue(input.Value, prop.PropertyType)
                });
            }
            return(args);
        }