I got the following code that the DLL generates (example example):
public class PluginClass { private string _MyString; public string MyString { get { return _MyString; } set { _MyString = value; RaisePropertyChanged("MyString"); } } public int MyInt; public SpeedGenerator SpeedGenerator1 = new SpeedGenerator(); public GaugeValueGenerator GaugeValueGenerator1 { get; set; } public PluginClass() { GaugeValueGenerator1 = new GaugeValueGenerator(); } }
As you can see, I have 4 fields / properties.
1 primitive field (primitive - int / string / bool / etcetc ...): MyInt 1 primitive property: MyString 1 object field: SpeedGenerator1 1 object property: GaugeValueGenerator1
When I parsed my DLL, I had to make code that is in a function: WriteProperty
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance); var props = type.GetProperties(); foreach (FieldInfo field in fields) { WriteProperty(field.FieldType, field.Name, XXX); } foreach (PropertyInfo prop in props) { WriteProperty(prop.PropertyType, prop.Name, XXX); }
My question is about XXX, which is a boolean indicating whether my field / property is "primitive". Therefore, it must be set to false if it is an object. I fell as if I tried everything, but I canβt solve it ... Any help would be greatly appreciated!
(My idea was to call
var props = propertyType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
and note that it must be empty for simple / primitive types! But no ... for example, in String, this returns the properties Chars (char []) and Length (int) ...)
(nb: Of course, I do not want to do a line operation in the /property.Name/FullName field ... something like
if ((propertyType.FullName).Contains("System."))
will be very very juicy ... and inaccurate)