Imports System.Configuration
Imports System.Xml
Public Class ProviderSectionHandler
  Implements IConfigurationSectionHandler

  Dim _providers As XmlNode
  Public Function Create(ByVal parent As Object, ByVal configContext As Object, ByVal section As System.Xml.XmlNode) As Object Implements System.Configuration.IConfigurationSectionHandler.Create
    Select Case section.Name
      Case "Charter.Website.ECommerceGateway.Providers"
        _providers = section
        Return Me
      Case "Receivers"
                Dim receivers As New Dictionary(Of String, BLCommon.Receivers)
                For Each receiverData As XmlNode In section.ChildNodes
                    receivers.Add(receiverData.InnerText, CType(receiverData.Attributes("ID").Value, BLCommon.Receivers))
                Next
        Return receivers
      Case Else
    End Select
  End Function

  Public ReadOnly Property ProviderData(ByVal name As String) As XmlNode
    Get
      For Each _provider As XmlNode In _providers
        If _provider.Attributes("name").Value = name Then
          Return _provider
        End If
      Next
      Return Nothing
    End Get
  End Property

End Class
