用户可写配置文件的示例?

发布于 2024-11-17 04:42:01 字数 994 浏览 1 评论 0原文

我的 (C# 4.0) 项目中迫在眉睫的是引入用户配置功能,其中我的同事需要获得配置我们的软件或预运行基础的能力,以便它能够以任何需要的方式履行其职责。每次运行(它们往往是冗长的模拟)都会有自己的配置文件。

总的来说,他们想要定义“产品”,相当复杂的野兽,包括运行时参数、IOC 样式信息(策略模式类似的方式)以及更多的东西。值可以是数字(整数和浮点)、字符串、日期及其列表。

我们知道随着新产品的推出或现有产品的发展,内容会发生变化(例如新的参数名称)。

我看过的选项包括,按(我估计的)语法重量的降序排列:

  1. XML
  2. YAML
  3. JSON一个>
  4. 一个<一个href="http://martinfowler.com/bliki/DomainSpecificLanguage.html" rel="nofollow">域特定语言?
  5. 一些特定于应用程序的文本符号

我正在寻找或多或少相似的事物的示例:文件格式、从技术和/或用户角度讨论优缺点。

(我希望在将来的某个时候,我们会考虑为此类练习引入图形前端,但我们需要能够在此之前的某个时间配置执行。)

编辑/更新:我特别关心从技术角度来看实施的难易程度:我正在寻找我的(非常聪明,但不面向技术的)用户最能够使用的东西来最小化编写相当复杂的配置的难度。

也许“配置”这个词是一个错误的选择 - 如果我们将其称为“模拟定义文件”并考虑到每个用户随着时间的推移会创建许多这样的文件怎么办?

Looming on my (C# 4.0) project horizon is the introduction of a user-configuration feature, wherein my colleagues need to obtain the ability to configure our software or a pre-run basis so that it will perform its duties in whatever way is needed. Every run (they'll tend to be lengthy simulations) will have have its own configuration file.

In the main, they'll want to define "products", fairly complex beasts comprising run-time parameters, IOC-style information (lists of calculation classes required in a Strategy Pattern-like way) and more stuff besides. Values could be numbers (integer and floating-point), strings, dates and lists of these.

We know the content will change (new parameter names, for example) as new products are introduced or existing ones evolve.

Options I've looked at include, in descending order of (my estimate of) syntax-heaviness:

  1. XML
  2. YAML
  3. JSON
  4. a DomainSpecific Language?
  5. Some app-specific text notation

I'm looking for examples of more-or-less similar things: file formats, discussions of pros and cons from a technical and/or user perspective.

(I expect that at some time in the future we'll consider introducing a graphic front-end for such exercises, but we'll need to be able to configure executions some time before then.)

EDIT/UPDATE: I'm not particularly concerned about ease of implementation from the technical perspective: I'm looking for something my (very smart, but not technically-oriented) users will best be able to use to minimize the difficulty of writing what may be a fairly complex configuration.

Maybe "configuration" is a bad choice of word - what if we called it "simulation definition file" and considered that each user will create many of these over time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陌生 2024-11-24 04:42:01

如果所有这些都可以用常规的、面向属性的方式来描述,那么听起来 XML 就能满足您的需求。 C# 具有出色的 XML 处理功能,包括内置序列化器和 LINQ,可以节省大量代码实现时间。此外,从架构创建基于表单的 UI 非常简单。

我建议坐下来创建一个伪模式,看看这是否可以处理您的用例,以帮助确定这种方法是否适合您。

例如,看一下由 XML 驱动的众多插件系统之一。我推荐的第一个是 Eclipse。

If all of this can be described in a regular, attribute oriented way, it sounds like XML would meet your needs. C# has fantastic XML handling features including built-in serializers and LINQ that can save a ton of code implementation time. Also, creating a forms based UI from a schema is very straight forward.

I would suggest sitting down and creating a pseudo-schema to see if this would handle your use cases to help decide if this approach would work for you.

For examples, take a look at one of the many plugin systems that are driven by XML. The first one I would recommend is Eclipse.

凤舞天涯 2024-11-24 04:42:01

在C#中,最简单的方法是使用内置类System.Configuration,首先您应该使用Visual Studio添加一个配置文件,然后您可以编辑它的属性。这是操作方法

In C# easiest way is to use a Built In Class System.Configuration ,first you should add an Configuration File ,using Visual Studio ,than you can edit it's attributes . Here is a How To

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文