.NET Scripting block

The .NET Scripting block allows you to manipulate fields through a script, which takes advantage of the endless capabilities provided by the Microsoft™ .NET Framework and the C# and VB.NET programming languages.

NOTE: CSense provides secure native blocks and operations for building analytics and solutions. The native capabilities provided by CSense can be extended by making use of this feature. When making use of this feature, please ensure that you have validated your extended functions to ensure that they perform as intended and do not introduce stability or security risks to your production system. Do not use scripts or components from untrusted sources.

Return to Overview of blocks

Description

The .NET Scripting block allows you to introduce new fields or manipulate existing ones, by means of code written in either C# or VB.NET. The value, timestamp and quality of output fields are controlled by this script. The script is run from top to bottom every time the block executes. You may define any variable from the standard .NET namespace in the script itself, or as a state field if you want to keep values intact between executes. Even though it is not possible to define your own classes and methods in the script, any other language operations are allowed.

 

.NET scripting block

Block Type

Rules and Models

Input port

The input port can accept any number and any type of fields.

Output port

The number and types of output fields are determined by the configuration of the block.

Functions performed on tags

The values, timestamps and qualities of fields are controlled by the script. Value, timestamp and quality behavior changes as follows:

  • On the Values: stays unmodified if the script does not assign a value to it. During the first execution the output value is 0, or blank in the case of a string data field, unless set to another value explicitly.

  • On the Quality:  stays unmodified if the script does not assign a value to it. During the first execution the quality is bad, unless set to another value explicitly.

  • On the Timestamp: stays unmodified if the script does not assign a value to it. During the first execution the time stamp is a value that is before any other possible timestamp, unless set to another value explicitly.

Whenever the value or the quality of a field changes between consecutive executes, it is compulsory for that field’s timestamp to progress in time.

Terminology

  • .NET: The .NET Framework is a large library of pre-coded solutions to common programming problems and manages the execution of programs written specifically for the Framework.

  • .NET object: A component created within the .NET Framework.

  • C#:(Pronounced C Sharp). An object-oriented programming language supporting the Microsoft™ .NET Framework.

  • Script: A script here refers to a segment of either C# or VB programming code, which allows you to manipulate your custom state fields and output fields. This includes access to the values from the input ports of the block.

  • VB.NET – Visual Basic .NET is an object-oriented language implemented on the Microsoft™ .NET Framework.

Return to top


Related topics:

  

CSense 2023- Last updated: June 24,2025