C#中的表达评估方法 [英] Methods of Expression Evaluation in C#

查看:109
本文介绍了C#中的表达评估方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要一个C#中的字符串表达式评估器.经过四处搜寻,我得出的结论是,只有两种方法(我可以理解:P)来创建评估器:使用反射和使用JavaScript.哪一个更好?有没有比这两种方法更容易更好的方法?

希望你们能帮助我

谢谢

Hi guys,

I need an evaluator for string expressions in C#. After searching around, i came to the conclusion that there are only two methods (which i could understand :P) to create an evaluator: using reflection and by using JavaScript. Which one is better? is there another method which is easier and better than these two methods?

Hoping you guys can help me out

Thank you

推荐答案

无.您可以使用C#作为输入语言,使用CodeDom进行编译并运行.后者有点困难,因为您需要在单独的应用程序域"中进行所有操作,但最终的价值是:您无需使用任何第3部分代码,而应使用符合ECMA和ISO标准的可用软件. >
这是我描述的此类应用程序的框架:
创建使用可重载插件的WPF应用程序... [ ^ ]
使用CodeDom生成代码 [ http://www.sakryukov.org/freeware/calculator/ [ ^ ].这只是一个文件,您可以复制和使用if.

在两种情况下,都是相同的想法:使用能够编译或解释相同语言代码的语言(带有运行时库).如果是.NET,它也可以是任何标准.NET语言.

—SA
None. You can use C# as input language, compile it using CodeDom and run. The latter is a bit difficult as you need to do all in a separate Application Domain, but the ultimate value is: you don''t use any 3rd part code and use available software which is compliant with ECMA and ISO standard.

Here is the skeleton of such application I depicted:
Create WPF Application that uses Reloadable Plugins...[^]
code generating using CodeDom[^]

To confuse you some more, here is my Javascript-only calculator: http://www.sakryukov.org/freeware/calculator/[^]. This is just one file, you can copy and use if.

In both cases, the same idea: using the language (with run-time library) capable of compiling or interpreting code on the same language. In case of .NET, it can be any of standard .NET languages as well.

—SA


这篇关于C#中的表达评估方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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