English 中文(简体)
定义.NET 应用程序 SIU 中的表达式的标准方式吗?
原标题:Standard way to define expressions in .NET application s UI?
  • 时间:2012-05-27 11:09:08
  •  标签:
  • c#

也许有人已经回答了以下概念性问题:

我正在写一个(相对微不足道的)应用程序,它从表格中记录记录(每行都是记录,圆柱是字段),处理记录,然后将新记录写进新的表格。

问题是,规格(即产出记录看起来如何以及如何计算)将随时发生变化,用户在编程方面没有多少经验。

我想把应用程序设置在UI 中, 也就是说, 我想让用户能够指定表达式, 例如

x * y - 3

z.Substring (2)

somewhere in the UI (similar to Excel, where you can give f或mulas f或 cells).

Question: What is the best language f或 specifying simple mathematical, boolean, and string expressions?

我考虑了以下各点:

  • allow the users to enter PowerShell code
  • allow the users to enter C# code
  • writing a parser myself

但是在我看来 这一切似乎都非常复杂 你有更好的主意吗?

最佳回答

Javascript is a pretty simple to use a simple. 我建议给用户一份源列列表, 并允许用户在 javascript 中指定一个变换函数, 然后您可以通过 http://jurassic.codeplex.com/wikipage 等图书馆在运行时对它进行评估? title= Calling% 20a% 20JavaScript%20 confident% 20from%20. NET & amp; referring Title=Documentation" rel="nofol" > Jurassic 。

问题回答

这是"的工作 http://en.wikipedia.org/wiki/Dynamic_Language_Runtime" rel = “nofollow” >DLR ! 它是为动态语言设计的。 您可以选择已经使用的任何语言 。 我只要选择 < a href=> http:// ironpython. net/" rel=“ nofollow” >iron python , 让用户以 python 语句输入表达方式。 它是一个绝对的梦想!

检查如何在 c# 程序中主机 irson python 引擎的极端简单示例

http://secretgeek.net/host_ironpython.asp" rel="no follow">http://secretgeek.net/host_ironpython.asp

您可以使用< a href=> http:// irony.codeplex.com/" rel=“ no follow” >Irony 创建您自己的具有必要功能的表达式评估器。 在 < a href=> 中已有简单的表达式和 Python 评估器 。 http:// irony.codeplex. com/resources control/ list/ changesets" rel=“ no follow” >samples 。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签