RealBasic的自省与我预期的有点不同。
我的意图是:
为简化起见,创建一个MainObject,其他对象将从中继承两个或三个方法。
Method 1-> Returns to the child class itself all of its properties, types and values.
Method 2-> Would call Method1 and with the information, save the child Object.
因此,对于方法1,我考虑编写一个泛化的内省,对于每个子类,它可以很容易地返回方法2完成其工作所需的内容。
为什么我想要这个?所以我可以有几十个对象知道如何保存,绘制自己,而不用太担心在属性等方面的修改。
但是使用RealBasic教程和参考资料是行不通的,因为它需要我在对象之外进行,等等。例如:我可以很容易地在ObjectA中获取ObjectB的属性、方法等,但我想在ObjectA中获取A的属性,而不是B的属性
先谢谢你...
发布于 2012-12-26 16:37:05
我发现了如何..。非常简单,创建MainClass并在其中创建一个简单的方法WhoAmI,它可以返回一个数组、字典等……
Dim thisClassTypeInfo As Introspection.TypeInfo = Introspection.GetType(Self)
Dim thisClassProperties() As Introspection.PropertyInfo = thisClassTypeInfo.GetProperties
Dim thisClassMethods() As Introspection.MethodInfo = thisClassTypeInfo.GetMethods
For Each myProperty As Introspection.PropertyInfo In thisClassProperties
// Then here use myProperty.Name, myProperty.Value(Self).StringValue
// or myProperty.Value(Self).anyotheroption and create a dictionary
// or array with the results and return it.
Nexthttps://stackoverflow.com/questions/14033824
复制相似问题