最简单的获得一个交互式控制台我的应用程序的方式 [英] Simplest way to get an interactive console for my app

查看:643
本文介绍了最简单的获得一个交互式控制台我的应用程序的方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想演示我的应用程序的中间层的特点,还没有还创建一个用户界面的简单,互动的方式。我想一个互动的控制台。

I want a simple, interactive way to demo middle-tier features of my app which have not had a UI created yet. I want an interactive console.

在我的应用程序(WPF,但它不应该的问题)启动起来,我想也启动控制台窗口。这个窗口应该运行PowerShell的(或Ruby或Python,但preferably PowerShell的),并有其范围设置为访问我的服务定位。

When my application (WPF but it shouldn't matter) boots up I would like to also start a console window. This window should run powershell (or ruby, or python, but preferably powershell) and have its scope set to access my ServiceLocator.

另外,我也开始了我的应用程序,并从外部PowerShell窗口附加到该进程的AppDomain和抢参考服务定位。这甚至可能?

Alternately, I could start up my app and attach to the process appdomain from an external powershell window and grab a reference to the ServiceLocator. Is this even possible?

不管怎么说,我已经创建了IronRuby的引擎和之前设置的范围内的变量,但如果我去了这条道路,我需要从根本上创建自己的控制台输入/显示机制。

Anyways, I've created IronRuby engines and set variables in scopes before but if I went that route I would need to essentially create my own console input/display mechanism.

有谁知道一个更好的方式来进行此事?

Does anyone know of a better way to go about this?

推荐答案

您可以使用 ConsoleShell 的PowerShell。
是这样的:

You could use the ConsoleShell of PowerShell.
Something like:

using System.Management.Automation;
using System.Management.Automation.Runspaces;
...
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
runspaceConfiguration.Cmdlets.Append(...);
ConsoleShell.Start(runspaceConfiguration, Console.Title, Console.Title, new string[] { });
...

这将开始的PowerShell的过程中,你可以访问你的变量,添加与您的应用程序等进行交互的cmdlet。 该ConsoleShell为您提供了输入/输出机制,包括标签完成和命令行界面的其他功能。

This would start PowerShell within your process, and you could access your variables, add cmdlets that interact with your app etc'. The ConsoleShell gives you the input/output mechanism, including tab completion and other features of the command line interface.

这篇关于最简单的获得一个交互式控制台我的应用程序的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆