title: Getting List reference from object instance and PropertyInfo
body: <p>I have an instance of a unknown object and I am iterating through it's properties, I must retrieve each instance of each property, currently this is my solution:</p>
  
  <pre><code>private static void WriteMembers(object arg, XmlWriter writer, object[] attributes)
  {
      foreach (var property in arg.GetType().GetProperties())
      {
          if (attributes.All(x =&gt; x.GetType() != typeof (XmlIgnoreAttribute)))
          {
              if (property.GetIndexParameters().Length &gt; 0)
              {
                  //how to get list reference?
              }
              else
              {
                  var value = property.GetValue(arg, null);
  
                  if (value != null)
                  {
                      WriteMember(value, property.Name, writer, property.GetCustomAttributes(false));
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>But I can't use <code>PropertyInfo.GetValue</code> to get the list reference because it throws <code>TargetParameterCountException</code> since the list has an indexed property.</p>
  
  <p>How can I retrieve the list instance?</p>