I've been playing with a c# app that hosts IronPython, IronRuby, and (hopefully) PowerShell. Since IronPython and IronRuby were completely built on the DLR, the API for using them is pretty much identical.
IronPython.Hosting.Python.CreateEngine()
and
IronRuby.Ruby.CreateEngine()
both create instances of a Microsoft.Scripting.Hosting.ScriptEngine. Is there any hope of coercing PowerShell 3.0 to create a ScriptEngine? I have not been able to find much on the subject, other than PowerShell 3.0 seem be built on the DLR more than the previous version was (see http://huddledmasses.org/powershell-3-finally-on-the-dlr.
It doesn't appear that you can cast a PowerShell engine created with the following to a ScriptEngine.
System.Management.Automation.PowerShell.Create()
I suspect that if I really want to handle PowerShell through the same API I need to create my own ScriptEngine that wraps the PowerShell host.
PowerShell V3 does indeed use some of the DLR, but only parts that shipped in the .Net Frameworks V4. The DLR project had many useful apis that were not included in .Net, e.g. Microsoft.Scripting.Hosting.ScriptEngine.
If PowerShell wanted to implement the ScriptEngine apis, PowerShell would have had to ship those apis as part of PowerShell. The PowerShell team wasn't willing to take ownership of those apis.
So you are correct in assuming you need to wrap PowerShell with your own code if you want to implement ScriptEngine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With