public void Finds_SubSub_Property() { var p = PropertyPathHelper.GetProperty(typeof(MyFilteredItem), "MyInner.MySubSubItem.MySubSubString"); Assert.IsNotNull(p); Assert.AreEqual("MySubSubString", p.Name); Assert.AreEqual(typeof(string), p.PropertyType); }
public void Finds_Property_At_Top_Level() { var p = PropertyPathHelper.GetProperty(typeof(MyFilteredItem), "MyInt"); Assert.IsNotNull(p); Assert.AreEqual("MyInt", p.Name); Assert.AreEqual(typeof(int), p.PropertyType); }
private PropertyInfo ResolveProperty() { var target = TargetObject; var type = target.GetType(); var property = PropertyPathHelper.GetProperty(type, PropertyPath); if (property == null) { throw new ArgumentException($"Unable to find the property '{PropertyPath}' for the type '{type}'"); } if (!property.CanWrite) { throw new InvalidOperationException($"Unable to write for the property '{PropertyPath}' for the type '{type}'"); } return(property); }