CSharpScriptEngine 0.0.1
JOI Javascript Oriented Interoperability.

This module requires .NET 4.0 or higher. It works by starting my C# Evaluator based on Mono.CSharp from the Mono Runtime. Node will start a child REPL process. You send C# code by writing to the child's stdin and subscribe to its stdout.
Minimal
Minimal use. Define a string in C# environment.
const CSharpScriptEngine = let CSE = CSECSE
Less Minimal
Load assemblies programatically and inhabit their namespace.
/* IPC using CSE */let CSE = /* handle however you feel */ { console} /* sends "using $namespace" to process stdin */CSECSECSECSE CSE /* data is a console line */CSE /* initiate dialog with user/client */CSE
Methods
Using(namespace)
using will simply prepend "using " before line and append ";" after line before sending to stdin. Basically CSE.using('System.IO') is the same as CSE.write('using System.IO;')
/* can be written as chain */CSE ... /* suggested way */CSE
on(what, that)
wrap child_process.stdout.on to on()
write(line)
write line to CSE process stdin
REPL(void)
initiate REPL dialog with user/client
done nothing more to do
kill the child
Random technical details that could be useful
When CSE.exe evaluates an expression, it will stdout print "true" if it parsed correctly or "false" when you forget a semi colon or whatever. You can use this in your on.data event handler to determine what is happening.
If you want, you could prototype a method "getVar" that sends Console.WriteLine(varName.toString()) to the child process and then catch it with your handler function.
This package/module is experimental in general implementation as well as for myself. I strongly advise not to implement this in real world applications. However, if you do find a useful purpose for it or want to contribute, don't be shy and email me jochemstoel(@)gmail.com. That is after all why I publish these things in the first place.
Jochem Stoel
Involuntary public figure.
- https://www.npmjs.com/~jochemstoel
- http://jochemstoel.github.io/
- https://jochemstoel.tumblr.com/
- https://jochemstoel.nl/
- https://www.facebook.com/Jochem-Stoel-271292656217087/
- https://www.quora.com/profile/Jochem-Stoel