Link Search Menu Expand Document

C-Sharp Script Editor User Guide

Dec 6 2023 at 12:00 AM

  1. Description
  2. What To Expect
  3. Configuration of the C-Sharp Script Filter Node

Description

The following document serves as a guide on editing the Generic Driver using the C#/C-Sharp Script filter. Additionally, it offers background information on the filter itself. This versatile filter enables users to code C-Sharp Scripts, allowing for the manipulation of raw source data. Users can read or modify the data and have the flexibility to add, modify, and/or remove Payload values as needed. The script comprises one or more C# code files (.cs files), with one of them housing a class that implements the IoTnxt.Raptor.Generic.Filter.IPayloadExecutor interface. During compilation, the C# compiler loads all associated script files within the script project, compiling them collectively.

What To Expect

This document is designed to provide individuals with a clear understanding of the C-Sharp Editor filter. It offers guidance on configuring the C-Sharp Script filter and ensures users can use it easily and effectively.

Configuration of the C-Sharp Script Filter Node

This filter enables users to create a specific project with an advanced editor. The project will encompass code files that are subsequently posted to the API. In scenarios where users require data transformation beyond the capabilities of existing filters, they can leverage the C-Sharp Script to customise and adapt the data according to their specific needs. Data is extracted from the designated data sources and undergoes transformation before being transmitted to Commander. Users have the flexibility to edit and enhance the existing code within the template. Clicking the Configure the C-Sharp Script button in the C-Sharp Script filter node opens an editor called the C-Sharp project. This editor, presented as a folder containing C-Sharp Script files (.cs), serves as the platform for code creation and customisation.

Generic Driver

Figure 1 - Configure button

The user will be provided with a boilerplate main file called Main.cs. This file is the initial template that can be customised to meet the user’s specific requirements. Within this file, a main block of code is provided, executed within the ExecuteAsync function. Users can modify and tailor this code block according to their unique needs.

Generic Driver

Figure 2 - Main File

Additionally, users have the capability to create supplementary files that support the main file, allowing them to abstract information if the primary file becomes too extensive. This feature enables users to convert incoming payload data from the data source using custom code.

Basic functionality includes:

  1. Creating a New File: Users can generate new files to organize and manage code efficiently.
  2. Delete: Provides the ability to remove unwanted or obsolete files from the project.
  3. Save: Allows users to save their modifications and additions to the project files.

Generic Driver

Figure 3 - Functionality