Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inherited property does not set to itself
Message
De
22/01/2005 15:53:59
 
 
À
22/01/2005 14:05:16
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Divers
Thread ID:
00979501
Message ID:
00979674
Vues:
13
OK, I get it now. I think what you'll need to do is pass a parameter to your CheckLogin() function. Then it would work the way you want it to. I don't know if this the best way to solve this problem, as I said, I've never used shadowing, but I'm pretty sure it will accomplish what you need.

So, your base class would have:
    ' Check if the session is a valid one
    Public Function CheckLogin(string Login)
        Dim llSuccess As Boolean
        llSuccess = Framework.Security.LoginSession(Login, cData)
        If llSuccess = False Then
            Throw New System.Exception(Framework.Security.cError)
        End If
        nNoMember = Framework.Security.nNoMember
        cIdentification = nNoMember.ToString + "," + System.Web.HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") + ","
    End Function
and your sub-class, you'd have to call it like this:
  me.CheckLogin(cLogin)
How would that work for you?

~~Bonnie


>>I don't know much about "shadowing", as it seems to be a VB construct, but my guess is that you're not using it correctly. I've read about shadowing in the Help, so that's all I know about it. From your description of what's going on, I still can't quite figure out what you're trying to do that is not working. Could you explain it further by posting the relevant code?
>
>My Web Service class starts like this:
>
>
>Imports System.Web.Services
>
>Public Class LXWebService
>    Inherits System.Web.Services.WebService
>
>    Public cSession As String = ""
>    Public cStartupDirectory As String = Server.MapPath("")
>    Public nNoMember As Integer = 0
>    Public cIdentification As String = ""
>    Public cData As String = ""
>    Public cLogin As String = "Member"
>    Public cUrl As String = ""
>    Public cErrorDir As String = ""
>    Public cTempDir As String = ""
>
>    ' Check if the session is a valid one
>    Public Function CheckLogin()
>        Throw New System.Exception(cLogin)
>        Dim llSuccess As Boolean
>        llSuccess = Framework.Security.LoginSession(cLogin, cData)
>        If llSuccess = False Then
>            Throw New System.Exception(Framework.Security.cError)
>        End If
>        nNoMember = Framework.Security.nNoMember
>        cIdentification = nNoMember.ToString + "," + System.Web.HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") + ","
>    End Function
>
>End Class
>
>
>I only put one method in it to show a workable class. You can see that the class as several field definitions at the top. The one I am trying to make it work is cLogin. cLogin is having a default value of Member. Member is a name of a table used for the authentication.
>
>Then, my Web Service is defined like this:
>
>
>Imports System.Web.Services
>Imports System.IO
>Imports System.XML
>Imports Framework
>Imports System.Data.OleDb
>
><System.Web.Services.WebService(Namespace:="http://tempuri.org/WebService/Service1")> _
>Public Class DMIB
>    Inherits LXWebService
>
>    Shadows cUrl As String = Framework.FileFunction.GetIni(Me.cStartupDirectory + "\Main.ini", "System", "Server")
>    Shadows cTempDir As String = Framework.FileFunction.GetIni(Me.cStartupDirectory + "\Main.ini", "System", "Temp")
>    Shadows cData As String = Framework.FileFunction.GetIni(Me.cStartupDirectory + "\Main.ini", "System", "Data")
>    Shadows cErrorDir As String = Framework.FileFunction.GetIni(Me.cStartupDirectory + "\Main.ini", "System", "ErrorDir")
>    Shadows cLogin As String = "Login"
>
>    <WebMethod()> _
>    Public Function GetWebServiceVersion() As String
>        CheckLogin()
>        Dim loDirectory As New DirectoryInfo(Me.cStartupDirectory + "\Bin\")
>        ...
>    End Function
>
>
>So, it is a derived class from the one defined at the top. In here, I have to overwrite the default value of cLogin. So, cLogin is using the Login.dbf table.
>
>Inside this Web Service, when I access the cLogin field, it gives the proper value defined here. This is ok. So, for example, if before GetWebServiceVersion(), in the method I put in here, I would do:
>
>
>        Throw New System.Exception(cLogin)
>
>
>It would show "Login".
>
>But, if I do such as I have right now, by calling CheckLogin(), which is defined in the class, as this method resides inside the class, the value of cLogin defined in the derived class is no longer available. Instead, the method of the class would return "Member". So, basically, the class seems protected for its value that we can only change from a derived class but the value changed in the derived class is not available from a method of the class.
>
>As you can see, I have put:
>
>
>        Throw New System.Exception(cLogin)
>
>
>in CheckLogin() to see the value of the field which is frozen to the default value from that method.
>
>This is what I am trying to resolve. Basically, if I change a value from the derived class, why isn't it available in the class itself?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform