Console program gadget: input password, instruction assignment, auto complement and help integration

Source: Internet
Author: User
Tags string format

First, Introduction

The console program is small, convenient and easy to develop. Generally, when I write a project, I am accustomed to writing a console client outside the intended client. This has several advantages:

(1) The amount of development is much less than the Web or GUI.

(2) It is simple to run and has few resources.

(3) Easy to track the operation of the program. For example, the use of log4net log, the Appender-ref set to Consoleappender, you can clearly see the system running track, in the use of Nhibernate/activerecord development is particularly convenient.

(4) When developing two different UI for the same system, it will consciously do the layering, so that the hierarchy structure of the system can be clearer and easy to maintain.

However, although the development of the console program is small, there are still some common functions to achieve more cumbersome. For example, here are a few questions:

(1) Enter the password. When the user enters the password, the console displays * * * instead of the password plaintext;

(2) The resolution and dispatch of the instruction. In the console, it is often necessary to input a pure string format instruction to the program, parse the instruction, parse the number of parameters, and invoke the corresponding method.

(3) Instructions of the Help system. Displays all instructions and their descriptions.

(4) Automatic completion of the instruction.

These problems are often encountered in the write console program, so I wrote two classes Consoleutil and Cmddispatcher, to achieve the above functions for reuse. Download code for this.

The code is written by c#3.0, and to be used in other C # versions, you need to make some changes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.