[XIF] Getting default values from IRecord

[XIF] Getting default values from IRecord

  

I am creating a XIF that deals directly with IRecords.


Basically, it is a connector that converts an OutSystems structure passed by parameter in ToObject() to a different structure needed for a custom service integration.


I need to find out the default values of the attributes of a given IRecord.


In the following example, I want to somehow get "HELLOWORLD" from the MyValue attribute:



Any tips?


Thank you.

Solution

Found a way.


I can create a new record with the same type passing null to the constructor, which initializes its default values.


public static IRecord GetDefaultRecord(IRecord record)
        {
            // Creates a new record of the same type, which should contain all the default values
            return (IRecord)Activator.CreateInstance(record.GetType(), new object[] { null });
        }


Then I can just compare the value of the attribute of my record against the value of the same attribute on the default record. If the values are the same, then it's a default value.


Solution