in src/React.Core/JavaScriptEngineUtils.cs [43:65]
public static T CallFunctionReturningJson<T>(this IJsEngine engine, string function, params object[] args)
{
if (ValidationHelpers.IsSupportedType(typeof(T)))
{
// Type is supported directly (ie. a scalar type like string/int/bool)
// Just execute the function directly.
return engine.CallFunction<T>(function, args);
}
// The type is not a scalar type. Assume the function will return its result as
// JSON.
var resultJson = engine.CallFunction<string>(function, args);
try
{
return JsonConvert.DeserializeObject<T>(resultJson);
}
catch (JsonReaderException ex)
{
throw new ReactException(string.Format(
"{0} did not return valid JSON: {1}.\n\n{2}",
function, ex.Message, resultJson
), ex);
}
}