Skip to content

Instantly share code, notes, and snippets.

View fnicollier's full-sized avatar

Fabian Nicollier fnicollier

  • Yverdon-les-Bains
View GitHub Profile
var jsValue = new JsonParser(JsEngine).Parse(myJsonString); //Parse myJsonString into JsValue
var jsValue = JsValue.FromObject(JsEngine, myObject); //Convert myObject to JsValue
var methodPointer = processEngine.JsEngine.GetValue(jsMethod.Name); //Get the JS function from the Engine
jsMethod.Result = methodPointer
.Invoke(jsMethod.Parameters
.Select(p => processEngine.Results[p.Name])
.ToArray()); //Invoke the JS function with all the parameters it has defined by reading them from the Results dictionary
processEngine.Results.TryAdd(jsMethod.Name, jsMethod.Result); //Add the output of the invoked function to the Results dictionary
public sealed class Output
{
/// <summary>
/// The HTTP status.
/// </summary>
public int? HttpStatus { get; set; } = (int) HttpStatusCode.OK;
/// <summary>
/// The response.
/// </summary>
[
..
{ "key": "method1", "value": { "val1": "Sample Data" } },
{ "key": "method2", "value": "Sample Data" },
...
]
...
function method2(method1) {
return method1.val1; //The output of method1 is available as input as requested as parameter
}
{
"name": "Process1",
"tasks": [
{ "id": "method1", "type": "js", "parameters": [ "request", "process" ] },
{ "id": "method2", "type": "js", "parameters": [ "method1" ] },
...
]
}
/// <summary>
/// A DSL response.
/// </summary>
public sealed class ConnectorResponse
{
/// <summary>
/// Creates a new empty DSL Connector Response.
/// </summary>
public ConnectorResponse(string errorMessage, string status)
{
/// <summary>
/// The DSL connector interface.
/// </summary>
public interface IConnector
{
/// <summary>
/// The connector's name for reference from the orchestration file.
/// </summary>
string Name { get; }
function method1(request, process) {
...
return val1;
}