title: Know if Fields/Properties of an object are "simple/primitive" types or other objects?
body: <p>I got the following code that generate a DLL (sample exemple) :</p>
  
  <pre><code>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();
      }
  }
  </code></pre>
  
  <p>As you can see I got 4 fields/properties.</p>
  
  <p>1 primitive field (primitive is int/string/bool/etcetc...) : MyInt
  1 primitive property : MyString
  1 object field : SpeedGenerator1
  1 object property : GaugeValueGenerator1</p>
  
  <p>When Im parsing my DLL I got to do some code that is in the function : WriteProperty</p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>My question is on XXX that is a boolean that indicate if my field/property is "primitive". So it must be set to false if it is an object.
  I fell like I tried quite everything but I can't resolve it...
  Any help will be very appreciate !</p>
  
  <p>(My idea was to call</p>
  
  <pre><code>var props = propertyType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
  </code></pre>
  
  <p>and consider that it should be empty for simple/primitive types ! But no... for example on String, this return the properties Chars (char[]) and Length (int)...)</p>
  
  <p>(nb : Of course I don't wanna do a string operation on field/property.Name/FullName... something like</p>
  
  <pre><code>if ((propertyType.FullName).Contains("System."))
  </code></pre>
  
  <p>would be very very sucky... and inaccurate)</p>