1. Home
  2. Docs
  3. Documentation
  4. Plugins
  5. Plugin definition

Plugin definition

The very first step is to create interface and methods that will be executed remotely. Plugin interfaces should be defined in a standalone assembly, as this code will be accessed by both, the client and the server.

In an empty solution, add a project (Standard Library) named SB.Plugins.Demo.Core. This project will contain definitions of interfaces, Data Transfer Objects and other shared data.

Next, add NuGet package SB.PluginSDK to this project. This package contains everything needed for a definition of a plugin interface.

Finally, create the interface. Note that this is a bit different from the code in the demo project. By the end of this tutorial, the code will be the same.

using SB.PluginSDK;

namespace SB.Plugins.Demo.Core
    public interface ICalculatorServer : IPlugin
        int Sum(int a, int b);

In the code snippet above, interface ICalculatorServer is defined. There are three pieces you need to focus on:

  • ICalculatorServer implements IPlugin interface – all plugins must inherit IPlugin interface
  • ICalculatorServer has SBPlugin attribute – all plugins must have SBPlugin attribute, and the pluginKey (in this case, number 10) must uniquely identify this plugin
  • Method Sum has SBMethod attribute – each method in a plugin must have SBMethod attribute. MethodKeys must be unique within plugin

Method signatures should have only structs and POCO classes. Inheritance and non-empty constructors are not supported by design.

Next step: Plugin implementation.

Was this article helpful to you? Yes No

How can we help?