Writing your own plugin
ServiceStack allows you to write your own plugin by implementing the IPlugin
interface that resides in the root namespace (ServiceStack
). It needs to be added to the Plugins
collection of your host upon configuration.
using Funq; using ServiceStack; public class AppHost : AppSelfHostBase { public override void Configure(Container container) { this.Plugins.Add(new FooPlugin()); } } public class FooPlugin : IPlugin { public void Register(IAppHost appHost) { } }
The difference between this.Plugins.Add
and this.LoadPlugin
is very small and is as follows:
this.Plugins.Add
adds an instance to the registration queue that gets iterated through after host initialization.this.LoadPlugin
safely registers the providedIPlugin
instance. If the host is already initialized, it executes the registration routine, and otherwise callsthis.Plugins.Add
to add the instance to the queue.
You can extend your plugin further by implementing the IPreInitPlugin
interface and...