I wrote a code in python that reads a XML data model contains user defined types and user class definitions then converts in to C# class.
for example user creates this XML file:
<app:list name="myList" itemType="strering">
<app:restriction combination="any">
<app:minSize>1</app:minSize>
</app:restriction>
</app:list>
and my application will converts it to below C# code:
private System.Collections.Generic.List<strering> _myList;
public System.Collections.Generic.List<strering> myList {
get{ return _myList; }
set{
if (_myList == value)
return;
if ((value.Count>=1) || false){
_myList=value;
}
else {
throw new Exception("Inserted value for myList is not valid!");
}
RaisePropertyChanged ("myList"); // for binding to mvvm model
}
}
if strering is defined in XML file so my application can find it in the symbol table and passed it to another level, but my question is How can I understand that user entered list type is .Net built-in type or not?
If it’s code generation, use a second pass over the XML to know if there are complex types that have been read in the first pass. That’s generally how code generators work.
By just looking at the value, there’s really no unambiguous way to decide the try.
What I mean to say is that “stering” could be a string or an enumeration. So, you would have to add some logic to decide what should be generated.