Getting initiating class name in its base class's shared property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Is there any way of getting currently instantiated class name from a parent
class's shared readonly property? I would need to know which actual class
(that was derieved from the class containing the shared property) is trying
to get the shared property value. It would be something like this:

Public Class BaseClass
Public Shared ReadOnly Property PageConfig() As PageConfiguration
Get
Return PageConfigurator.GetConfig( [here i would like a derieved
class's name, if called through that] )
End Get
End Property
End Class

Public Class DerievedClass
Inherits BaseClass
Public Sub SomeMethod()
PageTitle = Me.PageConfig.Title
End Sub
End Class

Why does it need to be Shared? I need to call it also for the derieved class
from any other class that has nothing to do with the two above without
creating an instance of derieved class, like:

Public Class AnotherClass
Public Sub SomeMethod
Dim TargetUrl As String = DerievedClass.PageConfig.Url
End Sub
End Class

Am I missing something? Is this possible at all? This is so trivially used
in my projects and there are so many derieving classes that I would like to
accomplish this task without needing to code anything in derieving classes.
I've tried something with gettype and reflection without success.


Any help appriciated,
Pasi Häkkinen
 
Hi Pasi,

Currently, we are finding someone to help you on this issue, and we will
reply to you ASAP. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Why does it need to be Shared? I need to call it also for the derieved class
from any other class that has nothing to do with the two above without
creating an instance of derieved class, like:

Public Class AnotherClass
Public Sub SomeMethod
Dim TargetUrl As String = DerievedClass.PageConfig.Url
End Sub
End Class

Am I missing something? Is this possible at all? This is so trivially used
in my projects and there are so many derieving classes that I would like to
accomplish this task without needing to code anything in derieving classes.
I've tried something with gettype and reflection without success.

No, it's not possible - because the above would actually get compiled
(at least the C# equivalent would) as

Dim TargetUrl As String = BaseClass.PageConfig.Url
 
Hi Pasi,

I agree with Jon's suggestion.
If you need to shared information from a few class A instances, you may try
to create another class B, which will be notified when the A classes is
initialized.
So that the class B as a manage class will have the information stored for
sharing in the class A s.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top