Public Delegate Sub AppStringChangingHandler(ByVal sender As Object, ByVal e As AppStringChangingArgs)
Public Delegate Sub AppIntegerChangingHandler(ByVal sender As Object, ByVal e As AppIntegerChangingArgs)
Public Delegate Sub AppObjectChangingHandler(ByVal sender As Object, ByVal e As AppObjectChangingArgs)
Public Class AppStringChangingArgs
Inherits System.ComponentModel.CancelEventArgs
Public NewString As String
Public Sub New(ByVal value As String)
NewString = value
End Sub
End Class
Public Class AppIntegerChangingArgs
Inherits System.ComponentModel.CancelEventArgs
Public NewInteger As Integer
Public Sub New(ByVal value As Integer)
NewInteger = value
End Sub
End Class
Public Class AppObjectChangingArgs
Inherits System.ComponentModel.CancelEventArgs
Public NewObject As Object
Public Sub New(ByVal value As Object)
NewObject = value
End Sub
End Class
Public Class Globals
Protected Shared WithEvents mInstance As Globals
Private mString As String
Public Event AppStringChanging As AppStringChangingHandler
Public Event AppStringChanged As EventHandler
Protected Sub New()
End Sub
Public Property AppString() As String
Get
Return mString
End Get
Set(ByVal Value As String)
Dim args As New AppStringChangingArgs(Value)
RaiseEvent AppStringChanging(Me, args)
If args.Cancel Then Return
mString = Value
RaiseEvent AppStringChanged(Me, EventArgs.Empty)
End Set
End Property
Public Shared ReadOnly Property Instance() As Globals
Get
If mInstance Is Nothing Then mInstance = New Globals
Return mInstance
End Get
End Property
End Class
Public Class ExtendedGlobals
Inherits Globals
Private mInteger As Integer
Private mObject As Object
Public Event AppIntegerChanging As AppIntegerChangingHandler
Public Event AppObjectChanging As AppObjectChangingHandler
Public Event AppIntegerChanged As EventHandler
Public Event AppObjectChanged As EventHandler
Protected Sub New()
MyBase.New()
End Sub
Public Property AppInteger() As Integer
Get
Return mInteger
End Get
Set(ByVal Value As Integer)
Dim args As New AppIntegerChangingArgs(Value)
RaiseEvent AppIntegerChanging(Me, args)
If args.Cancel Then Return
mInteger = Value
RaiseEvent AppIntegerChanged(Me, EventArgs.Empty)
End Set
End Property
Public Property AppObject() As Object
Get
Return mInteger
End Get
Set(ByVal Value As Object)
Dim args As New AppObjectChangingArgs(Value)
RaiseEvent AppObjectChanging(Me, args)
If args.Cancel Then Return
mObject = Value
RaiseEvent AppObjectChanged(Me, EventArgs.Empty)
End Set
End Property
Public Shared Shadows ReadOnly Property Instance() As ExtendedGlobals
Get
If mInstance Is Nothing Then mInstance = New ExtendedGlobals
Return mInstance
End Get
End Property
End Class