views:

94

answers:

2

In the below mockup, how do I find out, if I am an instance of FooDAL or WeeDAL from within the method DoMagix()?

Public MustInherit Class DataAccessClass
    Public Sub DoMagix()
        '** LOOK AT ME!!! **
        'Who am I? Why am I here? Where am I going? 
        '** /LOOK AT ME!!! **
    End Sub
End Class

Public Class FooDAL
   Inherits DataAccessClass
End Class

Public Class WeeDAL
   Inherits DataAccessClass
End Class

My OO-skills are teh suck, so if I get the terminology wrong, please slap me and set me straigth (in that order plz).

A: 

First the DoMagix should be "Overridable".

And you can use GetType(Me) inside DoMagix to know what type it is at runtime.

shahkalpesh
I think Overridable is not necessary; however, it should use Me.GetType(), which is polymorphic, and should get the correct type even with DoMagix not set as Overridable.
TimeSpace Traveller
Thanks. I corrected myself.
shahkalpesh
You should make this an answer, Timespace Traveller. :)
Kjensen
A: 

"Timespace traveller" wrote the answer in a comment:

I think Overridable is not necessary; however, it should use Me.GetType(), which is polymorphic, and should get the correct type even with DoMagix not set as Overridable.

Kjensen