Frage

RealBasic's Introspection is kinda of different than what I expected.

My intention is:

Create a MainObject from which other objects will inherit two, three methods, to simplify.

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.

So, for method 1 I thought about writing a generalised introspection which for each child class would easily return what I need for Method 2 to do its work.

Why do I want this? So I can have tens of objects knowing how to save, draw themselves without worrying too much about a modification here or there on the properties etc...

But using what RealBasic tutorials and reference offers doesn't work, since it requires me to have it happening outside the object etc... i.e.: I can easily, inside ObjectA, get ObjectB's properties, methods etc, but I want to get inside ObjectA, A's properties, not B's

Thanks in advance...

War es hilfreich?

Lösung

I've found out how... Very simple, create the MainClass and inside of it a simple method WhoAmI which could return an array, dictionary etc...

  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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top