master
Harald Wolff 2019-03-29 08:55:05 +01:00
parent 70311e4c94
commit 54f466c363
1 changed files with 30 additions and 10 deletions

View File

@ -17,6 +17,7 @@ using Newtonsoft.Json.Linq;
using System.Runtime.CompilerServices;
using System.Linq;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace ln.http.resources
{
public class CallableAttribute : Attribute
@ -65,8 +66,16 @@ namespace ln.http.resources
private object InvokeMethodCall(string methodName, object[] arguments)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
MethodInfo methodInfo = FindMethodSignature(methodName, arguments.Length);
return methodInfo.Invoke(this, arguments);
object result = methodInfo.Invoke(this, arguments);
stopwatch.Stop();
Logging.Log(LogLevel.DEBUG,"InvokeMethodCall({0},...): {1}ms",methodName,stopwatch.ElapsedMilliseconds);
return result;
}
private object InvokeMethodCall(string methodName, KeyValuePair<string,object>[] arguments)
@ -82,7 +91,15 @@ namespace ln.http.resources
for (int n=0;n<parameterInfos.Length;n++)
pl[n] = args[parameterInfos[n].Name];
return methodInfo.Invoke(this, pl);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
object result = methodInfo.Invoke(this, pl);
stopwatch.Stop();
Logging.Log(LogLevel.DEBUG, "InvokeMethodCall({0},...): {1}ms", methodName, stopwatch.ElapsedMilliseconds);
return result;
}
@ -135,16 +152,19 @@ namespace ln.http.resources
methodResult = new MethodResult();
methodResult.MethodName = methodCall.MethodName;
MethodInfo methodInfo = FindMethodSignature(methodCall.MethodName, methodCall.Parameters.Length);
ParameterInfo[] mp = methodInfo.GetParameters();
object[] arguments = new object[methodCall.Parameters.Length];
//MethodInfo methodInfo = FindMethodSignature(methodCall.MethodName, methodCall.Parameters.Length);
//ParameterInfo[] mp = methodInfo.GetParameters();
for (int n=0;n<methodCall.Parameters.Length; n++)
{
arguments[n] = Convert.ChangeType(methodCall.Parameters[n], mp[n].ParameterType);
}
methodResult.Result = methodInfo.Invoke(this, arguments);
//object[] arguments = new object[methodCall.Parameters.Length];
//for (int n=0;n<methodCall.Parameters.Length; n++)
//{
// arguments[n] = Convert.ChangeType(methodCall.Parameters[n], mp[n].ParameterType);
//}
//methodResult.Result = methodInfo.Invoke(this, arguments);
methodResult.Result = InvokeMethodCall(methodCall.MethodName, methodCall.Parameters);