An open API service indexing awesome lists of open source software.

https://github.com/alsiola/declarativeconsolemenu

Make complex C# console menus simple.
https://github.com/alsiola/declarativeconsolemenu

Last synced: about 1 year ago
JSON representation

Make complex C# console menus simple.

Awesome Lists containing this project

README

          

# DeclarativeConsoleMenu

A simple and declarative way of building console menus of any depth and complexity.

A simple class library to easily build complex console menus in a declarative fashion.

Available from [nuget](https://www.nuget.org/packages/DeclarativeConsoleMenu/) as DeclarativeConsoleMenu

# Usage
```c#
class MenuGenerator
{
public static MenuCollection CreateMenuCollection()
{
MenuCollection collection = new MenuCollection();

//Declarative way of building a menu, there are also generator methods you can use.
return new MenuCollection()
{
Menus = {
new Menu()
{
// give the menu an identifier
MenuId = 1,
MenuItems =
{
new MenuItem()
{
Text = "Open Sub Menu",
// if you want to link to another menu, then set the other menu's id
SubMenuId = 2
},
new MenuItem()
{
Text = "Print hello world!",
//or if you want to perform an action, set the Action property
Action = () => Console.WriteLine("Hello World!")
}
}
},
new Menu()
{
MenuId = 2,
MenuItems =
{
new MenuItem()
{
Text = "Print Hello",
Action = () => Console.WriteLine("Hello")
},
new MenuItem()
{
Text = "Print Goodbye",
Action = () => Console.WriteLine("Goodbye")
},
new MenuItem()
{
Text = "Back to the top menu",
SubMenuId = 1
}
}
}
}
};
}
}
```