I have a PolygonRenderer class containing a Vertices property, which is a List, holding the points of the polygon the class renders.
When I try to change a specific point in this list by reflection, I get a System.Reflection.TargetParameterCountException on the last line of my function :
public override void ApplyValue(string property, object value, int? index)
{
List<PropertyInfo> properties = Data.GetType().GetProperties().ToList();
PropertyInfo pi = properties.FirstOrDefault(p => p.Name == property);
pi.SetValue(Data, value,
index.HasValue ? new object[] { index.Value } : null);
}
When I debug, I get index.Value = 3, Data is the PolygonRenderer instance and pi reflects the Vertices property, which count = 4.
Since my index is supposed to be the last item of my list, how is it possible that I get a count exception on that property ?
Thanks
Aucun commentaire:
Enregistrer un commentaire