31
Views
2
Comments
Solved
C# Extension of Any Type
Question

Hi there,

I am wondering, suppose i create a C# extension for stack abstract data type and its element is a certain type that is not known until the user call the stack. Suppose end user have a structure of Racer data type and then use the stack extension. How the code in that C# extension to work with any data structure that end user supply - can be Racer, can be others  - ?

In other words, how to map any Outsystems data type to C# extension - as an input to C# and also as an output from C#? 

regards and thanks

Rank: #484
Solution

Hi,

On OS side you will need to use the ToObject() action to convert your record structure to a generic .net object, then in the extension use the C# Reflection class to manipulate it's attributes.

You can refer to the code in the following forge components for an idea of how to derive the attributes from the object:

https://www.outsystems.com/forge/component-overview/484/record-introspect

https://www.outsystems.com/forge/component-overview/5391/objecttorecordlist-using-c-reflection

Rank: #218

Thank you very much, Sir. I'll explore.