Skip to content
Author: ytianle

Life Cycle⚓︎

The lifecycle of a plugin system is usually described in four stages:

  • Load: the host discovers plugin metadata and loads the plugin binary/module (C# uses .dll, assembly) into memory in runtime.
  • Initialize: the plugin receives host services, validates configuration, and prepares resources.
  • Execute: the host invokes the plugin through the contract/API during normal operation.
  • Unload: the host stops the plugin and releases related resources.

Here is a simplified sequence diagram:

sequenceDiagram
    autonumber
    participant Host as Host Application
    participant Manager as Loader / Manager
    participant Plugin as Plugin

    Host->>Manager: Discover available plugins
    Manager->>Plugin: Load plugin binary / module
    Manager->>Plugin: Initialize(config, host services)
    Plugin-->>Manager: Ready

    loop Runtime execution
        Host->>Manager: Request plugin capability
        Manager->>Plugin: Execute through contract/API
        Plugin-->>Manager: Return result / event
        Manager-->>Host: Deliver result
    end

    Host->>Manager: Shutdown or disable plugin
    Manager->>Plugin: Unload / dispose resources
    Plugin-->>Manager: Cleanup complete

This diagram emphasizes the role of the Loader / Manager as the coordinator between the Host Application and the Plugin during the whole lifecycle.