首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在RealBasic上实现自省?

如何在RealBasic上实现自省?
EN

Stack Overflow用户
提问于 2012-12-26 04:34:51
回答 1查看 434关注 0票数 2

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的属性

先谢谢你...

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-26 16:37:05

我发现了如何..。非常简单,创建MainClass并在其中创建一个简单的方法WhoAmI,它可以返回一个数组、字典等……

代码语言:javascript
复制
  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.

  Next
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14033824

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档