控制台应用程序结构 [英] Console Application Structure

查看:68
本文介绍了控制台应用程序结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的6个月中,我已经编写了多个.Net控制台应用程序,而在我们组织的不同项目中,我们还有许多其他应用程序。我通常对控制台应用程序使用相同的标准格式/结构。不幸的是,我们的许多控制台应用程序都没有。

I've written several .Net Console Applications over the past 6 months and we have many more throughout different projects in our organization. I generally stick to the same standard format/structure for my Console Applications. Unfortunately, many of our console applications do not.

我一直在研究标准化这些控制台应用程序结构的方法。我还想为控制台应用程序的基本结构提供一个框架,并提供对处理诸如参数传递,日志记录等处理的标准方式的轻松访问。

I have been looking into ways of standardizing the structure of these Console Applications. I would also like to provide a framework for the basic structure of a Console Application and provide easy access to standard ways of handling things such as argument passing, logging, etc.

谁能提出解决这些问题的最佳做法?我一直在 .Net中的控制台应用程序上阅读此MSDN文章。建议使用控制台应用程序的设计模式。该示例使用模板方法模式来处理我之前列出的一些问题。

Can anyone suggest Best Practices for addressing these concerns? I have been reading this MSDN article on Console Applications in .Net which suggests a Design Pattern for Console Apps. The example uses a Template Method pattern to handle some of the concerns I listed earlier.

本文列出了使用此方法的两个缺点。

Two negatives of using this approach are listed in the article.


  • 最终获得两倍的课程

  • 具有许多简单,相似的课程

有人可以提出更好或更标准的处理方法吗?用这种方法列出其他否定内容怎么办?

Can anyone suggest better, or more standard, ways of handling this? What about listing additional negatives with this approach?

推荐答案

要回答我自己的问题的一部分...

To answer part of my own question...

我确实花了很多时间寻找一种标准方法来处理传递到控制台应用程序的参数解析。我专门在寻找类似于GetOpt for python的东西。考虑到这一点,我选择的解决方案是 NDesk.Options 。它涵盖了我们的所有需求,并且似乎以标准方式处理参数。我认为这可能会对在搜索中偶然发现此问题的人有所帮助。

I did spend quite a bit of time looking for a standard way to handle the parsing of arguments passed to my console applications. I was specifically looking for something similar to GetOpt for python. With that in mind, the solution that I settled on is NDesk.Options. It covers all of our needs and seems to handle arguments in a standard fashion. I thought this might help someone who stumbles on this question in their search.

这篇关于控制台应用程序结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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