Last active
December 26, 2015 13:39
-
-
Save glennblock/7159969 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Func<IDictionary<string, object>, Task<object>> Invoke(Func<IDictionary<string, object>, object> executor) | |
{ | |
Func<IDictionary<string, object>, Task<object>> invoker = null; | |
if (executor.Method.ReturnType != typeof (Task<object>)) | |
{ | |
invoker = | |
p => | |
{ | |
var task = new Task<object>(() => executor(p)); | |
task.Start(); | |
return task; | |
}; | |
} | |
else | |
{ | |
invoker = p => (Task<object>) executor(p); | |
} | |
return invoker; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var edge = require('edge'); | |
var hello = edge.func('scs', function() {/* | |
Invoke(d=>d["value"]) | |
*/}); | |
hello({"value": "Hello from scriptcs"}, function(error,result) { | |
if (error) throw error; | |
console.log(result.Result); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var edge = require('edge'); | |
var hello = edge.func('scs', function() {/* | |
Func<IDictionary<string,object>, Task<object>> execute = p=> Task.FromResult<object>(p["value"]); | |
execute | |
*/}); | |
hello({"value": "Hello from scriptcs"}, function(error,result) { | |
if (error) throw error; | |
console.log(result.Result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment