MCPcopy Create free account
hub / github.com/NodeRT/NodeRT / GetParamsFromTsMethodForDefinitions

Method GetParamsFromTsMethodForDefinitions

src/NodeRTLib/Reflector.cs:397–438  ·  view source on GitHub ↗
(dynamic method, bool isAsync = false)

Source from the content-addressed store, hash-verified

395 }
396
397 public static string GetParamsFromTsMethodForDefinitions(dynamic method, bool isAsync = false)
398 {
399 var sb = new StringBuilder();
400 string commaString = string.Empty;
401 foreach (var paramInfo in method.GetParameters())
402 {
403 string optionalString = string.Empty;
404 if (paramInfo.IsOptional)
405 {
406 optionalString = "?";
407 }
408 sb.Append(commaString);
409 sb.Append(paramInfo.Name);
410 sb.Append(": ");
411 sb.Append(Converter.ToJsDefinitonType(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)));
412 commaString = ", ";
413 }
414
415 if (isAsync)
416 {
417 System.Reflection.MethodInfo[] returnTypeMethods = method.ReturnType.GetMethods();
418 Type resultType = returnTypeMethods.Where((methodInfo) => { return (methodInfo.Name == "GetResults"); }).First().ReturnType;
419
420 string resultTypeString = Converter.ToJsDefinitonType(resultType, TX.MainModel.Types.ContainsKey(resultType));
421 string errorTypeString = "Error";
422
423 string errorParam = string.Format("error: {0}", errorTypeString);
424 string resultParam = string.Format("result: {0}", resultTypeString);
425
426 string callbackParams = errorParam;
427 if (resultType != typeof(void))
428 {
429 callbackParams += ", " + resultParam;
430 }
431
432 string callbackSignature = string.Format("callback: ({0}) => void", callbackParams);
433 sb.Append(commaString);
434 sb.Append(callbackSignature);
435 }
436
437 return sb.ToString();
438 }
439
440 public static string ToWinRT(Type type, bool generateHat = true)
441 {

Callers 5

foreachFunction · 0.80
foreachFunction · 0.80
foreachFunction · 0.80
foreachFunction · 0.80
foreachFunction · 0.80

Calls 3

AppendMethod · 0.80
ToJsDefinitonTypeMethod · 0.80
FirstMethod · 0.45

Tested by

no test coverage detected