generateConstructor method
Generates code that constructs a representation of the type from an expression
as an XML attribute / XML element / XML text.
An implementation to construct a representation of the type as an XML text could be as simple as:
String generateConstructor(String expression) => 'XmlText($expression)';
Implementation
@override
String generateConstructor(String expression) {
final buffer = StringBuffer();
if (_isNullable) {
buffer.write('$expression != null ? ');
}
buffer.write('XmlAttribute(XmlName(\'$_name\'');
if (_namespace != null) {
buffer.write(', namespaces[\'$_namespace\']');
}
buffer.write('), $expression)');
if (_isNullable) {
buffer.write(' : null');
}
return buffer.toString();
}