Different ways to access a record inside an extension

Different ways to access a record inside an extension

  
There are two ways to pass a record to an extension "Variable.EntityName" or "Variable" only. My problem is inside the XML extension, if I pass the record in first format I can access to the parameters of the record and serialize it XML, however if I pass in the second format I could not reach the record content in a generic way to all record types.

In attach there the XML solution changed with a test method to simulate these two cases (class CssXml, method MssTeste_toObject).

Any one has an idea how to solve it?

Thanks in advance,
Luís Campos.