Table of Contents

Creating a Module

We will show how to implement a Random Number module in 4 steps

Tip

Namespaces used on this page

  • using Crosser.EdgeNode.Flows.Models.Abstractions.Models;
  • using Crosser.EdgeNode.Flows;

To create a custom module we have to inherit the class FlowModule<T>.

The base class force you to implement a few things:

  • The UserFriendlyName property
  • A call to the base class constructor saying what FlowModuleType the module is
  • The implementation of MessageReceived
Tip

You can also implement other methods to handle lifecycle events. These are covered in Module Lifetime

public class RandomNumberModule : FlowModule<RandomNumberModuleSettings>
{
    public override string UserFriendlyName => "Random Number";

    public RandomNumberModule() : base(FlowModuleType.Function) {}

    protected override Task MessageReceived(IFlowMessage message)
    {
        // We will cover this in step: Receive Messages
        throw new NotImplementedException();
    }
}

Since we did not create the RandomNumberModuleSettings class yet this will not compile.

Next step is defining the settings!

>> Settings