Mapping from C# object to structure

Mapping from C# object to structure

  
Hi guys,

I'm developing an extension that imports a .NET Assembly that takes as request an ID, calls a service with said ID and responds with a customer. A customer is defined by a series of attributes (name, surname, age, etc...).

Right now I had to define a structure and an action to map the customer to the structure in integration studio.

I wanted to know if it's possible to directly map the customer's attributes from the C# code into a structure.

Best regards,
David
What do you mean by directly map?

You can copy from your c# class struct to an outsytems structure.

First you loop through your c# array list, then you copy the content into an outsystems structure record list and thats it. 

RCMyItemRecord rec = new RCMyItemRecord(null); //Create a new record
rec.ssSTMyItem.ssName = "your value goes here"; //assign record with value
ssSTMyItem.Append(rec); //copy the record to the outsystems structure


 
Robert Chanphakeo wrote:
What do you mean by directly map?

You can copy from your c# class struct to an outsytems structure.

First you loop through your c# array list, then you copy the content into an outsystems structure record list and thats it. 

RCMyItemRecord rec = new RCMyItemRecord(null); //Create a new record
rec.ssSTMyItem.ssName = "your value goes here"; //assign record with value
ssSTMyItem.Append(rec); //copy the record to the outsystems structure


 
What I needed was to import a .NET assembly with a method returning a structure to be used in OutSystems.
I would prefer if I didn't have to add structures, actions or customize the generated code to make the mappings. 
Is it possible?
I think that in your solution you edit the source code to map the variables.


Hi David,

This is not possible. A Platform record is a different beast than a simple structure. You'll need to convert whatever is returned by the external service / assembly to a Record or Record List in your extension.
Kilian Hekhuis wrote:
Hi David,

This is not possible. A Platform record is a different beast than a simple structure. You'll need to convert whatever is returned by the external service / assembly to a Record or Record List in your extension.
 Hi Kilian,

Thanks for the quick answer, that was exactly what I wanted to confirm.
I thought that there was a way of generating structures when importing .net assemblies. That would be great!
 
Well, importing a DLL is done in Visual Studio, which doesn't have any notion of the Platform. The only way would be to import DLLs directly with Integration Studio, but I don't see that happen, ever.
But you can import DLL in integration studio, replicating the methods into actions.
If the input/output of a method is a complex type, it doesn't generate a structure and calls the parameter an Object. All the mappings from Outsystems record to said object have to be done in a custom action.
 
Ah, I see, didn't know that. Yes, it would probably be nice if the Platform could do that automatically.