Imports CharterDotCom.CommonEntities.Library
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.CommonEntities.Library.EntityMemberServices
Imports CharterDotCom.CommonEntities.Library.EntityEBSServices
Imports CharterDotCom.CommonEntities.Library.EntitySupport
Imports CharterDotCom.CommonEntities.Library.EntitySearch
Imports CharterDotCom.CommonEntities.Library.EntityWebConfig
Imports CharterDotCom.CommonEntities.Library.EntityG2BServices
Imports System.Xml


Partial Class TestSearch
    Inherits System.Web.UI.Page

    Private _provider As ISearchProvider


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
      Dim lProvider As CharterDotCom.CommonEntities.Library.ISearchProvider = CType(Activator.GetObject(GetType(ISearchProvider), CStr(System.Web.HttpContext.Current.Application("RemoteURL_SearchProvider"))), ISearchProvider)

            Me.Provider = lProvider
        End If
    End Sub
    Private Property Provider() As ISearchProvider
        Get
            Return _provider
        End Get
        Set(ByVal value As ISearchProvider)
            _provider = value
        End Set
    End Property



    Protected Sub btnSearchSupport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearchSupport.Click
        Try
            Dim objresult As New SearchSupportResponse

            objresult = Me.Provider.SearchSupport("cable")

            Select Case True
                Case (objresult.SearchResultCollection Is Nothing)
                    Response.Write("Search Provider collection returned nothing")
                Case (objresult.SearchResultCollection.results Is Nothing)
                    Response.Write("Search Provider collection results returned nothing")
                Case Not (objresult.SearchResultCollection Is Nothing) And Not (objresult.SearchResultCollection.results Is Nothing)
                    Response.Write("Search Provider is working")
                    For Each item As SearchResult In objresult.SearchResultCollection.results
                        Response.Write(item.Title & "<br>")
                    Next
                Case Else
                    Response.Write("Search Provider has hit else, could be a problem.")
            End Select


        Catch ex As Exception
            Response.Write(ex.Message.ToString())
        End Try
    End Sub
End Class
