Public Class DSOUserContextBR
#Region "Member Variables"
private shared myInstance As DSOUserContextBR
Private m_Anmeldename As String
Private m_Workstation As String
#End Region
#Region "Properties"
Public ReadOnly Property User() As String
Get
Return m_Anmeldename
End Get
End Property
Public ReadOnly Property Workstation() As String
Get
Return m_Workstation
End Get
End Property
#End Region
#Region "Public Methods"
Public Shared Function GetInstance() As DSOUserContextBR
If myInstance Is Nothing Then
myInstance = New DSOUserContextBR()
End If
Return myInstance
End Function
Public Sub Initialize()
'So stuff with member variables
End Sub
#End Region
#Region "Private Methods"
Private Sub New()
'Dadurch, dass New() Private ist, kann niemand von ausserhalb
'ein neues Objekt erzeugen. Ha!
'Es muss also die öffentliche "getInstance" Methode verwendet werden,
'die auf die bestehende Instanz zeigt --> Singleton ! Voila!
m_Anmeldename = Environment.UserName 'Anmeldename
m_Workstation = Environment.UserDomainName 'Rechner
End Sub
#End Region