[OutSystems] About the type of data passed to the C # code of Extension

2 minute read

I tried to see what the type of data passed to the OutSystems Extension (C #) would be.
I couldn’t find the documentation, so I actually wrote the code and checked it.

environment

Personal Environment(Version 11.9.0 (Build 16900))
Service Studio(Version 11.8.8)
Integration Studio(Version 11.6.21)

Confirmation method

Changed to receive an argument as Object type in Extension, check the type in C # and return it.
At the same time, we are checking the implementation status of three Interfaces (C #) that can be used to determine the type of data that has passed.

public void MssCheckOSType(object ssInput, out string ssDataType, out bool ssIsIRecordAllocatable, out bool ssIsISimpleRecordAllocatable, out bool ssIsIOSListAllocatable) {
	var type = ssInput.GetType();
	ssDataType = type.FullName;
	ssIsIRecordAllocatable = typeof(IRecord).IsAssignableFrom(type);
	ssIsISimpleRecordAllocatable = typeof(ISimpleRecord).IsAssignableFrom(type);
	ssIsIOSListAllocatable = typeof(IOSList).IsAssignableFrom(type);
}

Examine the type in C

It uses the GetType method that inherits from the Object class.
The return type is Type, and the FullName property sets the namespace. I am getting the fully qualified type name including.

Examine the implementation of Interface

This is the method used in ardoJSON. Apply the typeof identifier to the Interface whose implementation you want to check and get an instance of Type type.
It is confirmed whether the value passed to the parameter (in this case, the Object type value passed to the Action parameter) can be assigned to the corresponding Interface by the Type type IsAssignableFrom method.

Confirmation result summary

I tried to tabulate the results of the actual investigation according to the “confirmation method”.

Data type Model name IRecord ISimpleRecord IOSList
Basic data type: Text System.String      
Basic data type: Decimal System.Decimal      
Structure: Simple ssHousesoftSampleExtensionDemo.STSampleStructure  
Structure: With child Structure ssHousesoftSampleExtensionDemo.STSampleWithChildStructure  
Structure: Defined in Extension ssHousesoftSampleExtensionDemo.STSampleInExtensionStructure  
Entity: Single / 1 record ssHousesoftSampleExtensionDemo.ENSample_DepartmentEntityRecord  
Entity: Single / List ssHousesoftSampleExtensionDemo.RLSample_DepartmentRecordList    
Entity: Join 1 record ssHousesoftSampleExtensionDemo.RCSample_EmployeeSample_DepartmentRecord    
Entity: Join list ssHousesoftSampleExtensionDemo.RLSample_EmployeeSample_DepartmentRecordList    
Record:Data Type Editor ssHousesoftSampleExtensionDemo.RCTextSampleRecord    

Type

Observing the above results,
–The basic data type seems to use the built-in class representation of .NET.
–Classes corresponding to data other than the basic data type are placed in the namespace of the format “ss ". --Structure is a class name in the format "ST \ Structure" --One record of a single Entity is a class name in the format "EN \ ENtityRecord" --One record of the joined query result is a class name in the format "RC \ <Entity name 1> \ <Entity name 2> ... Record" --One record edited with Data Type Editor is similar, and the class name is in the format of "RC \ <component data type 1> \ <component data type 2> ... Record". --List type is a class name in the format "RL \ List"

Interface
Observing the above results,
–If it is a list type, implement only the IOSList interface regardless of the individual record type.
–Each record does not implement any of the three Interfaces if it is a basic data type
–IRecord implements records that are not basic data types
–Entity and Record implement ISimpleRecord. However, if you have a joined Entity and other records in your element, take a peek

reference

Although it is a little different from the official document, there is a description in the official course about the type of data used in Extension (PDF of the material).
Extension of logic in C # code