Interface contracts

The Energy.Interface namespace defines contracts used across the library. Implementing these interfaces allows your own classes to integrate with Energy.Core utilities such as collections, workers, pools, and SQL dialects.

Lifecycle

Interfaces for objects that can be started, stopped, created, and destroyed.

Interface Purpose
IStart Object has a Start() method.
IStop Object has a Stop() method.
IRunning Object exposes a Running property.
IStopped Object exposes a Stopped property.
IAbort Object can be aborted.
IDestroy Object can be destroyed.
ISleep / ISleepTime Object can sleep.
IWake Object can be woken.
IWork Object can perform work.

Workers and pools

Interface Purpose
IWorker Composite worker contract (IWork, IStart, IStop, IStopped, IRunning, IAbort).
IPool Pool contract (ISpawn, IStart, IStop, IRunning).
ISpawn / ISpawnObject / ISpawnType Object spawning.

Collections

Interface Purpose
IArray<T> Array operations.
IQueue<T> Queue operations.
IStack<T> Stack operations.
IRow<TKey, TValue> Row data access.
ITable<TKey, TValue> Table data access.
IColumn<TKey, TValue> Column data access.
IStringList String list operations.

Text processing

Interface Purpose
IEscape Text escaping.
IQuote Text quoting.
IStrip Text stripping.
IUnescape Text unescaping.

File and serialization

Interface Purpose
ILoadFromFile Load from file.
ISaveToFile Save to file.
IFileHandle File read/write/seek.
IFileSystem File system operations (placeholder).
IEncapsulation Pack/unpack data.
ICopy<T> / ICopy Copyable objects.

Network

Interface Purpose
INetworkConnection Host/port settings.
ISocketClient Socket client.
ISocketConnection Socket connection.
ISocketServer Socket server.

Application and SQL

Interface Purpose
ICommandProgram Application lifecycle (Setup, Initialize, Run).
IDialect SQL dialect contract.
ILogger Logger contract.
IPurge Purge capability.
ITest Test capability.

Example

public class MyWorker : Energy.Interface.IWorker
{
    public bool Running { get; private set; }
    public bool Stopped { get; private set; }

    public void Start() { Running = true; }
    public void Stop() { Stopped = true; }
    public void Abort() { Stop(); }
    public void Work() { }
}