Dim myProperties() as Introspection.PropertyInfo = Introspection.GetType(self).GetProperties
For i as Integer=0 to Ubound(myProperties)
// if Property isa myClass then call method myMethod
next
How do I call a method of myClass on each of the properties of ‘self’ if the property isa myClass?
MethodInfo represents a method and .Invoke will call that method. PropertyInfo represents a property and .Value returns or sets the actual property. In your situation, once you get the value out of PropertyInfo it’s a regular reference and you don’t need to deal with Introspection to handle it.
My use of Variant might be throwing you. That’s so it can grab any type of property without error and then test for type afterwards. You could also query the PropertyInfo for its type before accessing .Value. I think like this
if myProperties(i).PropertyType.FullName = "myClass" then
dim c As myClass = myProperties(i).Value(self)
if c <> nil then c.myMethod
end
Maybe FullName should be just Name, and you’ll need to test for nil. In the previous version if the Variant is nil it won’t pass the IsA test.