Skip to content

Instantly share code, notes, and snippets.

@Foovanadil
Last active March 11, 2016 17:46
Show Gist options
  • Save Foovanadil/5488229b1ebe64ad0240 to your computer and use it in GitHub Desktop.
Save Foovanadil/5488229b1ebe64ad0240 to your computer and use it in GitHub Desktop.
VB version of the Time Provider... Like anyone would ever need this...
Public MustInherit Class TimeProvider
Private Shared _current As TimeProvider = DefaultTimeProvider.Instance
Public Shared Property Current As TimeProvider
Get
Return _current
End Get
Set
If Value Is Nothing Then
Throw New ArgumentNullException("value")
End If
_current = Value
End Set
End Property
Public MustOverride ReadOnly Property UtcNow As DateTime
Public Shared Sub ResetToDefault()
_current = DefaultTimeProvider.Instance
End Sub
End Class
Public Class DefaultTimeProvider
Inherits TimeProvider
Public Overrides ReadOnly Property UtcNow As Date
Get
Return DateTime.UtcNow
End Get
End Property
Private Shared _instance As TimeProvider
Public Shared ReadOnly Property Instance As TimeProvider
Get
Return If(_instance, New DefaultTimeProvider())
End Get
End Property
Private Sub New()
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment