Last active
March 11, 2016 17:46
-
-
Save Foovanadil/5488229b1ebe64ad0240 to your computer and use it in GitHub Desktop.
VB version of the Time Provider... Like anyone would ever need this...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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