TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chris Riley
NA
85
0
Best method to communicate with System.Console from a DLL
Jul 8 2010 6:22 AM
Hi,
I have written a set of classes that allow me to build a simple menu system, that outputs options to the system console and handles the selection of these options.
The classes are called;
ConsoleMenu
ConsoleMenuOption
ConsoleMenuBuilder
I create various ConsoleMenu's, each Menu has various ConsoleMenuOptions, a menu option consists of the option description, a sub menu (ConsoleMenu) to display upon the selection of the option, a menu option can also be configured to invoke a deleagate allowing me to perform various functions from these options, and it also has a flag to define if the option should cause the menu to exit, and therefore return to the previous menu (or exit application) once selected, ie. [5] Back .. when 5 is selected it will return to previous menu.
I now have several console applications that need to use this, and I would like to include these classes within my library (dll)
system.console is static and my question is; is there any way to reference this from the console application its self, within the dll.
Currently the only solution I can think of is to add various events such as Write, WriteLine, ClearScreen to the menubuilder .. then in the console application, when declaring a consolemenubuilder, the events should be configured to functions which take the parameters and communicate with the console directly. Another thing I have considered but not looked at yet, is declaring delegates for the console functions, then upon declaration of my menubuilder simply pass Console.Write, Console.WriteLine, Console.Clear as parameters in the constructor.
Any thoughts?
Many Thanks
Chris
Reply
Answers (
2
)
ListView
Drag from listbox and drop in picturebox C#