public void SimpleFunctionWithParameters( [MsbFunctionParameter(Name = "param1")] string testParameter1, [MsbFunctionParameter(Name = "param2")] int testParameter2, [MsbFunctionParameter(Name = "param3")] DateTime testParameter3, FunctionCallInfo functionCallInfo) { }
public void ReceivedPublishedEventViaMsb( [MsbFunctionParameter(Name = "message")] string stringParameter, FunctionCallInfo functionCallInfo) { this.receivedStringViaMsb = stringParameter; this.receivedFunctionCallViaMsb = true; }
public void SampleMsbFunction( [MsbFunctionParameter(Name = "NameOfStringParameterInDataFormat")] string stringParaneter, [MsbFunctionParameter(Name = "NameOfIntParameterInDataFormat")] int intParameter, FunctionCallInfo functionCallInfo) { Console.WriteLine($"Function Call via MSB: {stringParaneter} | {intParameter}"); }
public EventData SampleFunctionWithResponseEvent( [MsbFunctionParameter(Name = "testStringParam")] string testString, [MsbFunctionParameter(Name = "testNestedObjectParam")] Events.ComplexEvent testNestedObject, FunctionCallInfo functionCallInfo) { Log.Information("SampleFunctionWithResponseEvent has been called"); return(new EventDataBuilder(functionCallInfo.ResponseEvents["SimpleEventId"]).SetValue(new Events.SimpleEvent()).Build()); }
public EventData SampleMsbFunction( FunctionCallInfo functionCallInfo) { Console.WriteLine($"Function Call via MSB"); return(new EventDataBuilder(functionCallInfo.ResponseEvents["ResponseEvent1"]) .SetEventPriority(EventPriority.HIGH) .SetShouldBeCached(true) .SetValue(new MyComplexEvent()) .Build()); }
public Constructors() { var methodInfo = this.GetType().GetRuntimeMethod("MsbFunction", new Type[] { typeof(FunctionCallInfo) }); this.expectedFunction = new Function("id", "name", "description", methodInfo, this); this.testFunctionCallInfo = new FunctionCallInfo( this.expectedMsbClient, this.expectedCorrelationId, this.expectedService, this.expectedFunction, this.expectedResponseEvents); }
public void TestFunction( [MsbFunctionParameter(Name = "testParameter")] int testParameter, FunctionCallInfo functionCallInfo) { if (testParameter.GetType().Equals(typeof(int))) { this.testFunctionCallReceived = true; } else { Log.Error($"Expected parameter type '{typeof(int)}' but was '{testParameter.GetType()}'"); } }
public void MsbFunctionWithoutResponseEvent(FunctionCallInfo functionCallInfo) { }
public void addWorld([MsbFunctionParameter(Name = "input")] string input, FunctionCallInfo info) { string result = input + " World!"; Console.WriteLine(result); }
private void HandleFunctionCall(FunctionCall functionCall) { Log.Debug($"Callback for function '{functionCall.FunctionId}' of service '{functionCall.ServiceUuid}' received with parameters: {functionCall.FunctionParameters}"); if (this.RegisteredServices.ContainsKey(functionCall.ServiceUuid)) { var serviceOfFunctionCall = this.RegisteredServices[functionCall.ServiceUuid]; if (serviceOfFunctionCall.Functions.Find(function => function.Id == functionCall.FunctionId) is Function functionOfService) { var pointer = functionOfService.FunctionPointer; var parameters = functionOfService.FunctionPointer.Method.GetParameters(); var parameterArrayForInvoke = new object[parameters.Length]; foreach (var functionCallParameter in functionCall.FunctionParameters) { var currentParameterCallIndex = AbstractFunctionHandler.GetParameterIndexFromName(functionOfService.FunctionPointer.Method, functionCallParameter.Key); var currentParameterCallType = functionOfService.FunctionPointer.Method.GetParameters()[currentParameterCallIndex].ParameterType; object deserializedParameter = null; if (OpenApiMapper.IsPrimitiveDataType(currentParameterCallType)) { deserializedParameter = Convert.ChangeType(functionCallParameter.Value, currentParameterCallType); } else { var valueAt = functionCallParameter.Value.ToString(); deserializedParameter = JsonConvert.DeserializeObject(valueAt, currentParameterCallType); } parameterArrayForInvoke[currentParameterCallIndex] = deserializedParameter; } var calledFunction = serviceOfFunctionCall.GetFunctionById(functionCall.FunctionId); Dictionary <string, Event> responseEvents = new Dictionary <string, Event>(); foreach (var responseEventId in calledFunction.ResponseEventIds) { responseEvents.Add(responseEventId, serviceOfFunctionCall.GetEventById(responseEventId)); } var functionCallInfo = new FunctionCallInfo(this, functionCall.CorrelationId, serviceOfFunctionCall, calledFunction, responseEvents); parameterArrayForInvoke[parameterArrayForInvoke.Length - 1] = functionCallInfo; try { var returnValue = functionOfService.FunctionPointer.DynamicInvoke(parameterArrayForInvoke); if (returnValue != null) { EventData responseEventData = (EventData)returnValue; if (responseEventData.Event.Id.Equals(EventData.NoResponseEvent.Event.Id)) { Log.Info("No response event sent because result of function exuction was 'EventData.NoResponseEvent'"); } else { if (calledFunction.ResponseEventIds.Contains(responseEventData.Event.Id)) { responseEventData.CorrelationId = functionCall.CorrelationId; #pragma warning disable CS4014 // Da dieser Aufruf nicht abgewartet wird, wird die Ausführung der aktuellen Methode fortgesetzt, bevor der Aufruf abgeschlossen ist this.PublishAsync(serviceOfFunctionCall, (EventData)responseEventData); #pragma warning restore CS4014 // Da dieser Aufruf nicht abgewartet wird, wird die Ausführung der aktuellen Methode fortgesetzt, bevor der Aufruf abgeschlossen ist } else { Log.Error($"Response event not published, because event '{responseEventData.Event.Id}' wasn't defined as response event of function '{calledFunction.Id}'"); } } } } catch (ArgumentException e) { Log.Error($"Failed to invoke function with received parameters: {e}"); } } else { Log.Warn($"Function call can't be processed, function '{functionCall.FunctionId}' not found in service '{functionCall.ServiceUuid}'"); } } else { Log.Warn($"Function call can't be processed, service '{functionCall.ServiceUuid}' wasn't registered via this MsbClient"); } }
public FunctionCallInfo MakeBindingFor(FunctionCallSyntax syntax, FunctionCallInfo value) { FunctionCallsBindings[syntax] = value; return(value); }
public void SampleFunctionWithParameters([MsbFunctionParameter(Name = "a")] string a, [MsbFunctionParameter(Name = "b")] Events.SimpleEvent input2, FunctionCallInfo info) { Log.Information($"SampleFunctionWithParameters has been called with the following parameters: a={a} ; input2.myInteger={input2.MyInteger}"); }
public void EmptySampleFunction(FunctionCallInfo info) { Log.Information("EmptySampleFunction has been called"); }
public void sum([MsbFunctionParameter(Name = "Ints")] IntegerValues Ints, FunctionCallInfo info) { int result1 = Ints.val1 + Ints.val2; Console.WriteLine(result1); }
public EventData MsbFunctionWithResponseEvent(FunctionCallInfo functionCallInfo) { return(new EventDataBuilder(functionCallInfo.ResponseEvents["ResponseEvent1"]).Build()); }
public void MsbFunctionWithResponseEventAndWrongReturnType(FunctionCallInfo functionCallInfo) { }
public void SimpleFunctionWithNoParameters(FunctionCallInfo functionCallInfo) { }
public bool MsbFunctionWithoutResponseEventAndWrongReturnType(FunctionCallInfo functionCallInfo) { return(false); }
public void SimpleFunction(FunctionCallInfo functionCallInfo) { }
public void MsbFunctionWithoutSpecifiedProperties(FunctionCallInfo functionCallInfo) { }
public EventData ReceivedPublishedEventViaMsbAndSendResponseEvent( [MsbFunctionParameter(Name = "message")] string stringParameter, FunctionCallInfo functionCallInfo) { return(new EventDataBuilder(functionCallInfo.ResponseEvents["TestResponseEvent"]).SetValue(stringParameter).Build()); }
public EventData MsbFunctionWithSpecifiedProperties(FunctionCallInfo functionCallInfo) { return(new EventDataBuilder(functionCallInfo.ResponseEvents["ResponseEvent1"]).Build()); }
public EventData NoResponseEventShouldBeSendForFunctionCallMsbFunction( FunctionCallInfo functionCallInfo) { return(EventData.NoResponseEvent); }
#pragma warning disable xUnit1013 // Public method should be marked as test public void MsbFunctionWithNotMsbFunctionAttribute(FunctionCallInfo functionCallInfo) { }
public static bool IsFunctionCall(string line, out FunctionCallInfo info) { //test (20); //teset(ToDeg(Sin(PI))); //Func(RandX(),Rand(20,50)); //for (int i = 0; i < 20, i++) //if (True) //int x = Rand(0,100); info = null; string[] split = line.Split(new[] { '(' }, 2, StringSplitOptions.RemoveEmptyEntries); //test 20); //teset ToDeg(Sin(PI))); //Func RandX(),Rand(20,50)); //for int i = 0; i < 20, i++) //if True) //int x = Rand 0,100); if (split.Length < 2) { return(false); } split[0] = split[0].TrimEnd(); if (FunctionNames.Fuctions.Contains(split[0]) && !split[1].EndsWith(";")) { throw new ParsingException("Missing semicolon after a function call!", line); } split[1] = split[1].TrimEnd(';', ' '); //test 20) //teset ToDeg(Sin(PI))) //Func RandX(),Rand(20,50)) //for int i = 0; i < 20, i++) //if True) //int x = Rand 0,100) split[1] = split[1].Remove(split[1].Length - 1, 1); //test 20 //teset ToDeg(Sin(PI)) //Func RandX(),Rand(20,50) //for int i = 0; i < 20, i++ //if True //int x = Rand 0,100 if (IsType(split[1].Split()[0], out _)) { return(false); } if (split[0].TrimEnd() == "for" || split[0].TrimEnd() == "if") { return(false); } if (split[0].Contains("=")) { return(false); } FunctionCallInfo i = new FunctionCallInfo(); i.FunctionName = split[0].TrimEnd(); i.Arguments = ArgParser.Parse(split[1].TrimEnd()); info = i; return(true); }
public void MsbFunctionWithFunctionCallInfoAtWrongPosition(FunctionCallInfo functionCallInfo, bool otherParameter) { }
public void MsbFunction(FunctionCallInfo functionCallInfo) { }
private void FunctionCalledHandler(Hook hook, IProcess aProcess, NktHookCallInfo hookCallInfo) { var aFunctionCallInfo = new FunctionCallInfo(hook, aProcess, hookCallInfo); _functionCallHandler.Handle(aFunctionCallInfo); }