Introduction
The imbACE framework is all about rapid console tool applications development. The project’s goal is to provide completely automated UI/TUI/GUI generation, for multiple platforms – using data annotation and meta information from your IAceAdvancedConsole implementations. The consoles are execution context classes, where the ACE Script Operations (methods, that are interpreted also as ACE Script command) are the main construction blocks. The concept is: you should code only your scientific contribution, wasting no time on the interface and reporting side of the project. This, of course, means, constrained design of the User Interface and/or other outputs. The framework is made for scientists, researchers and technical professionals, that need custom software tools for their specific tools but can’t care less to design and packaging of the tool.
Learn more:
Tutorial: Creating imbACE Console Application
In this tutorial we will:
- Create a imbACE Console Application project, using template, and configure it for first build
- Add an ACE Script Operation, that prints “Hello World!”
- Demonstrate basic user input prompts
Let’s start!
1. Create new Project
using [imbACE Console Application multi-target] project template, that you’ll find under imbACE template folder. This tutorial assumes that:
- you have downloaded and installed imbACE BasicPack extension for Visual Studio
- you’ve completed the Getting started with multi-target project or you are skilled enough to skip it.
Name the project “MyConsole” and confirm.
Right click on the Project > Manage NuGet Packages for the project
imbACE.Services.Standard is the top layer of imbACE application framework. Whatever is the current version, install the latest package available.
In directory console, we have three classes, “aceAdvancedConsole bundle” (btw. you can create new bundle using “Advanced Console bundle” Item Template):
- CommandConsoleState : aceAdvancedConsoleStateBase
- The State object keeps current and temporary data about Console‘s operation. If the Console was closed regularly, the State is saved automatically and loaded back once a console of same Type is loaded (in future, it will require sessionID as Consoles will have multi-user capability, i.e. server/client architecture).
namespace MyConsole.console { using System; using System.Collections.Generic; using System.Text; using imbACE.Services.console; // place here properties with data you want to preserve during and between the sessions/app. runs public class CommandConsoleState:aceAdvancedConsoleStateBase { public CommandConsoleState() { } } }
- CommandConsoleWorkspace : aceAdvancedConsoleWorkspace
- The Workspace provides access to permanent data storage, reserved for that Console implementation class (Type). Using Workspace, the Console can save or load ACE Scripts, different resources and keeep its “personal” data cache or repository.
using imbACE.Services.console; public class CommandConsoleWorkspace : aceAdvancedConsoleWorkspace { /// <summary> /// Initializes the workspace for the MyConsole console /// </summary> /// <param name="console">The console using this workspace</param> public CommandConsoleWorkspace(CommandConsole console) : base(console) { } // public folderNode folderName {get; set;} // <---- uncomment if you have need for additional subdirectory in the console state project folder /// <summary> /// Gets called during workspace construction, the method should initiate any additional subdirectories that console's project uses /// </summary> public override void setAdditionalWorkspaceFolders() { // place here your additional directories for console's project subdirectory as follows: // folderName = folder.Add(nameof(folderName), "Caption", "Description"); } }
- CommandConsole : aceAdvancedConsole<CommandConsoleState, CommandConsoleWorkspace>
- The Console (inheriting: aceAdvancedConsole) type is bound, via generic type parameters, to its (dedicated) State and Workspace. Normally, one instance of Console, has only one State and Workspace at the time.
namespace MyConsole.console { using imbACE.Services.console; public class CommandConsole : aceAdvancedConsole<CommandConsoleState, CommandConsoleWorkspace> { public override string consoleTitle { get { return "MyConsole Console"; } } public CommandConsole() : base() { } /// <summary> /// Gets the workspace. /// </summary> /// <value> /// The workspace. /// </value> public override CommandConsoleWorkspace workspace { get { if (_workspace == null) { _workspace = new CommandConsoleWorkspace(this); } return _workspace; } } public override void onStartUp() { // base.onStartUp(); } protected override void doCustomSpecialCall(aceCommandActiveInput input) { } } }
- MyConsoleApplication:ConsoleApplication:aceConsoleApplication<CommandConsole>
- On top of hierarchy is Application<Console> (single) instance, automatically constructed with start of the application. Although, one application can host multiple Console instances and multiple Console Types, the Main Console (class) is the one provided via generic type parameter.
namespace MyConsole { using imbACE.Core.application; using imbACE.Services.application; using MyConsole.console; public class ConsoleApplication : aceConsoleApplication<CommandConsole> { public static void Main(string[] args) { var application = new ConsoleApplication(); application.StartApplication(args); // here you may place code that has to be performed after user called application termination // ... } public override void setAboutInformation() { // Insert proper information here appAboutInfo = new aceApplicationInfo(); // parametarless constructor takes values from Assembly attributes appAboutInfo.license = "Licensed under GNU General Public License v3.0"; appAboutInfo.welcomeMessage = "imbACE Console Tool"; } } }
In Project .csproj file, you’ll find disabled block, that sets MSBuild to create Windows Console Application exe. Remove comment tags and run Debug
<PropertyGroup> <!-- The node below enables XML documentation build, in all build (Debug,Release) configurations--> <DocumentationFile>$(OutputPath)$(PackageId).xml</DocumentationFile> <!-- Uncomment the block below to build Console Application and not just library/package --> <OutputType>WinExe</OutputType> <StartupObject>MyConsole.MyConsoleApplication</StartupObject> </PropertyGroup>
(btw. you could set Windows Application build from GUI but… this was fun)
Elements:
- Application (ConsoleApplication:IAceAd
- Creating your imbACE Advanced Console Plugin
- Using data annotation to export collection of objects to Excel and CSV files
- Using other snippets and templates