Energy Core Standard
This document describes standard behavior for the Energy.Core application framework.
Application
ICommandProgram lifecycle
When Energy.Core.Application.Run() is called, the following methods are invoked in order:
Setup(args)— parse command-line arguments and configure the program.Initialize(args)— initialize resources.Run(args)— execute the program.
If any method returns false, the run sequence stops.
Workers
Worker
A worker starts a thread that calls
Work().The worker should check the
Stoppedproperty periodically.Sleep(int)andSleep(double)pause the worker without consuming CPU.Waitreturnstrueif the thread exits within the timeout.
Logging
Log.Default
Log.Defaultis a singletonLogger.Use
Setup(file, console, eventHandler)to add common destinations.Flush()writes buffered entries to all destinations.
Configuration
Configuration.Create
Reads command-line options.
Maps them to fields and properties decorated with
Energy.Attribute.Command.OptionAttribute.Supports short, long, and alternative option names.