private Variant Invoke(RemoteMethod method) { try { Variant result = method.Invoke(this); return(result); } catch (Exception e) { ExceptionHandler.Log(e, $"Cannot invoke {Name}.{method.Name}() without errors!"); } return(method.HasReturnValue() ? method.ReturnValue : Variant.Null); }
public Variant CallMethod(RemoteMethod remoteMethod, ref NodeId methodNodeId) { var methodName = remoteMethod.Name; if (string.IsNullOrWhiteSpace(methodName)) { throw new Exception("Method name is empty!"); } if (_parentNode == null) { throw new Exception($"Parent node is null for method '{methodName}'!"); } if (methodNodeId == NodeId.Null) { methodNodeId = BrowseNodeId(_parentNode, methodName, false); } List <StatusCode> inputArgumentErrors; List <Variant> outputArguments; // call the method on the server. var result = _session.Call( _parentNode, methodNodeId, remoteMethod.InputArguments, out inputArgumentErrors, out outputArguments); if (remoteMethod.HasReturnValue() && outputArguments.Count > 0) { remoteMethod.ReturnValue = !result.IsGood() ? Variant.Null : outputArguments[0]; } return(remoteMethod.ReturnValue); }