想要编写 C# 应用程序脚本
我需要对我们的 C# 客户端-服务器配置运行一些验证测试。 是否有我的客户端应用程序可以运行的动态脚本语言 拥有对其所有 C# 类和程序集的完全访问权限?
类似java的beanshell: http://www.beanshell.org/intro.html
谢谢!
I need to run some validation tests on our c# client-server configuration.
Is there a dynamic script language that my client application could run, that would
have full access to all of its C# classes and asssemblies?
Something like beanshell for java: http://www.beanshell.org/intro.html
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为您最好的选择是 Windows Powershell。
I think your best option would be Windows Powershell.
IronPython 怎么样?
How about IronPython?
如果您的应用程序是 ASP.NET 应用程序,则可以使用 App_Code 文件夹在 C# 中有效地编写脚本。在应用程序的文件夹中,创建一个名为 App_Code 的文件夹并在其中放置一个 .cs 文件。对此文件的任何更改都将由 ASP.NET 编译器动态编译,并导致应用程序重新启动。此代码将有权访问应用程序中的所有程序集。
要执行此代码,您可以连接到应用程序事件,也可以在应用程序中编写一段代码来动态发现和调用它,例如通过使用 App_Code 类实现已知接口并进行程序集扫描当您的应用程序启动时。
If your application is an ASP.NET application, you can effectively script it in C# using the App_Code folder. In the application's folder, create a folder called App_Code and drop a .cs file in there. Any changes to this file will be dynamically compiled by the ASP.NET compiler and result in a restart of the application. This code will have access to all of the assemblies in your app.
To get this code to execute, you can hook up to an application event or you can write a piece of code in your application to dynamically discover and call it, for example by implementing a known interface with an App_Code class and doing an assembly scan for it when your app starts.
我建议尝试 Mono 的 Evaluator 类,它具有用于评估单个语句或代码块(作为委托返回)的方法。
I recommend trying out Mono's Evaluator class, which has methods for evaluating single statements or code blocks (which are returned as delegates).