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.
- Host: GitHub
- URL: https://github.com/alsiola/declarativeconsolemenu
- Owner: alsiola
- License: mit
- Created: 2016-12-15T19:00:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T15:55:49.000Z (over 3 years ago)
- Last Synced: 2025-03-30T14:22:24.393Z (about 1 year ago)
- Language: C#
- Size: 10.7 KB
- Stars: 14
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
}
}
}
}
};
}
}
```