我一直在使用一个托管IronPython、IronRuby和(希望能够)PowerShell的C#应用程序。由于IronPython和IronRuby完全基于DLR构建,因此使用它们的API基本相同。
IronPython.Hosting.Python.CreateEngine()
并且
IronRuby.Ruby.CreateEngine()
两者都创建了一个Microsoft.Scripting.Hosting.ScriptEngine的实例。有没有办法强制PowerShell 3.0创建ScriptEngine?除了PowerShell 3.0似乎建立在DLR 更多上面,我没有找到太多关于这个主题的信息(请参见http://huddledmasses.org/powershell-3-finally-on-the-dlr)。
从以下代码创建的PowerShell引擎似乎不能转换为ScriptEngine。
System.Management.Automation.PowerShell.Create()
我怀疑如果我真的想通过相同的API处理PowerShell,我需要创建自己的ScriptEngine来包装PowerShell主机。