ProcessContainer

Inversion of control (IoC) container that runs as a system process.

Inherits: Container

Description

The ProcessContainer class allows you to create an inversion of control (IoC) container that runs as a system process.

Important points

  • It processes command line arguments and handles unhandled exceptions and Ctrl-C signal to shutdown the container properly.

Command line arguments

  • –config / -c path to a JSON or YAML file with the container’s configuration (default: “./config/config.yml”)
  • –param / –params / -p configuration parameters
  • –help / -h prints the container usage help

Constructors

Creates a new instance of the container.

public ProcessContainer(string name = null, string description = null)

  • name: string - (optional) container’s name (accessible via ContextInfo)
  • description: string - (optional) container’s description (accessible via ContextInfo)

Fields

_configPath

Path to the configuration file.

protected _configPath: string = “./config/config.yml”

Instance methods

Run

Runs the container by instantiating and running components inside the container.

It reads the container configuration, and creates, configures, references and opens components. On process exit; it closes, unreferences and destroys components in order to shutdown properly.

public Task RunAsync(string[] args)

  • args: string[] - command line arguments

Examples

var container = new ProcessContainer();
container.AddFactory(new MyComponentFactory());

container.RunAsync(process.getArgs());

See also