Created
May 4, 2011 22:33
-
-
Save atifaziz/956191 to your computer and use it in GitHub Desktop.
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
Option Explicit On | |
Option Strict On | |
Imports System | |
Imports System.ComponentModel.Design | |
Imports Elmah | |
Module MainModule | |
Class EnclosedServiceProviderQueryHandler | |
Private ReadOnly _parent As ServiceProviderQueryHandler | |
Private Sub New(parent As ServiceProviderQueryHandler) | |
_parent = parent | |
End Sub | |
Private Function Query(context As Object) As IServiceProvider | |
Dim container As New ServiceContainer(_parent(context)) | |
Dim log As New SqlErrorLog("...connection string...") | |
container.AddService(GetType(ErrorLog), log) | |
Return container | |
End Function | |
Public Shared Function Create(parent As ServiceProviderQueryHandler) As ServiceProviderQueryHandler | |
Dim closure As New EnclosedServiceProviderQueryHandler(parent) | |
Return New ServiceProviderQueryHandler(AddressOf closure.Query) | |
End Function | |
End Class | |
Sub Main() | |
ServiceCenter.Current = EnclosedServiceProviderQueryHandler.Create(ServiceCenter.Current) | |
Dim log As ErrorLog : log = ErrorLog.GetDefault(Nothing) | |
Console.WriteLine(log.Name) | |
End Sub | |
End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment