Shared Method - Can a subclass get its TypeInfo?

I have a Shared Method on a class that gets subclassed.
Is there a way for the SharedMethod to know what subclass its being called from?

MyParentClass.DoMySharedMethod
versus
MyChildClass.DoMySharedMethod

The important part is I don’t want the subclasses to need to do any custom implementation of the shared method.
The shared method on the parent class essentially has a dictionary and I want the key’s to be the TypeInfo of the class invokes the method.

Essentially I have a DefaultEffectOptions that can get set and if a control doesn’t have its EffectOptions set it should use the default for that Class. If the class doesn’t have a DefaultEffectOptions in the dictionary then it will check for its parent etc…

A simpler question:

In a shared method how do I get the TypeInfo of the current class? Is this possible?

Seems like the Super needs a regular method that every sub does NOT override
Note there’s no FINAL to be able to say they cannot override it :frowning: <https://xojo.com/issue/18762>
Then every sub calls this method - NOT the shared (hence why the shared is private)

Like this

[code]MySuperClass
Method GetDefaultEffect
Call SharedDefaultEffect( self )
end method

Private Shared Method SharedDefaultEffect( obj as MySuperClass)
dim t as Introspection.TypeInfo = Introspection.GetType( obj )
break
end method
end

MySubClass inherits MySuperClass
End
[/code]

now somewhere else you can do

   dim c as new MySuperClass
  
  c. GetDefaultEffect
  
  c = new MySubClass
  
  c. GetDefaultEffect
  

and the break point will show you you have the type info for the specific subclass

EDIT : helps if I write it sort of right :stuck_out_tongue:

I’m actually ok with someone overriding the shared method. I just dont’ want their subclasses to require them to override/implement it.

Essentially I could do this two ways:

  1. Provide a non-shared method that accesses the shared method (I think this is what you meant above? - @Norman Palardy)

dim dummyInstance = new mySubClass dummyInstance.SharedDefualtEffect = effect

  1. Require the shared method to take a typeInfo parameter
myClass.SetSharedDefaultEffect(effect, GetTypeInfo(mySubClass))

I was hoping for this:

myClass.SharedDefaultEffect = effect

But that doesn’t seem possible unless a shared method has the ability to get its type info

Try what I said and make it an assigns method and you’re done

But doesn’t that require an instance in order to work?

GetDefaultEffect isn’t a shared method so I’m assuming so.

Of course it is an instance method
You can’t get type info without an instance - http://documentation.xojo.com/index.php/Introspection.GetType