Notice that I do not use the generic Set method for the properties structure, but instead rely on the C# class property. Also, note that your have to do a "SetProperties" after you have modified the properties structure, otherwise the engine will never be informed that the properties has changed.
And a small note on the line with the generic "Set" method for setting the variable definition: The engine will actually look for a property named "qDefinition", not "Definition" when evaluating a variable. The C# property "Definition" of the "GenericVariableProperties" class maps to that engine property. Actually, these two operations should be equivalent in your case:
Note that the property name starts with a 'q' in version 2)! The engine uses that prefix to identify properties that are to be evaluated by the engine. (Other typical examples you will encounter are "qHyperCubeDef" and "qListObjectDef".)