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:

  1. Setup(args) — parse command-line arguments and configure the program.

  2. Initialize(args) — initialize resources.

  3. 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 Stopped property periodically.

  • Sleep(int) and Sleep(double) pause the worker without consuming CPU.

  • Wait returns true if the thread exits within the timeout.

Logging

Log.Default

  • Log.Default is a singleton Logger.

  • 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.