title: Get value from a generic object property by reflection
body: <p>I just want to get main identifier from all domain object from a generic property.<br>
  The code until now:</p>
  
  <pre><code>IEnumerable&lt;PropertyInfo&gt; customProperties = genericObject.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
  
  foreach (PropertyInfo justAuditElementProperties in customProperties) {
  
      IEnumerable&lt;PropertyInfo&gt; elementsToAudit = justAuditElementProperties.PropertyType.GetProperties().Where(p =&gt; Attribute.IsDefined(p, typeof (AuditeAttribute)));
      foreach (PropertyInfo element in elementsToAudit) {
          string name = justAuditElementProperties.PropertyType.FullName + "." + element.Name;
          string value = element.GetValue( ? , null).ToString();
          atributoNomeValor.Add(name, value);
      }
  }
  </code></pre>
  
  <p>What's the correct replacement to <em>?</em></p>
  
  <p>--
  So is important to say that every main identifier has <code>[Audite]</code> attribute</p>
  
  <p><strong>edit</strong><br>
  The type of ? is the type of a Property of genericObject. example:<br>
  Department is genericObject.<br>
  Manager is a property. 
  So in this case I want <code>element.GetValue( ? , null).ToString();</code> where this element is a declared in Manager class as:  </p>
  
  <pre><code> [Audite]
   public string name { get; set; }
  </code></pre>
  
  <p><strong>Solution</strong><br>
  This use the solution from @liho1eye, I just added a null reference verification, that generate some problems for me.</p>
  
  <pre><code>var propertyParent = justAuditElementProperties.GetValue(genericObject, null);
  string value = propertyParent != null ? element.GetValue(propertyParent, null).ToString() : "";
  </code></pre>