public class SomeClass
{
public IBy Some1{ get { return By.CssSelector("span[id$=spanEarth]"); } }
public IBy Some2 { get { return By.CssSelector("span[id$=spanWorm]"); } }
public IBy Some3 { get { return By.CssSelector("span[id$=spanJim]"); } }
}
is the class, and I am using reflection in this fashion:
var gridRow = Type.GetType(typeof(SomeOtherClassInSameNamespace).AssemblyQualifiedName.Replace("SomeOtherClassInSameNamespace", "SomeClass"), true, true);
var rowList = gridRow.GetProperties().Where(p => p.PropertyType.Name.Contains("IBy")).ToList();
int i = 0;
foreach (var property in rowList)
{
string test = property.GetValue(gridRow, null).ToString();
}
Which gives a runtime error for an objectType exception. How do I get the values from the list of properties using Reflection?