Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Logging

Public Class Connection
    Public Function ParseServiceAddress(pHost As String, pPort As Integer) As ServerAddressStruct
        Dim oAddress As ServerAddressStruct

        oAddress.Host = pHost
        oAddress.Port = pPort

        Return oAddress
    End Function

    Public Function ParseServiceAddress(pAddress As String) As ServerAddressStruct
        Dim oAddressList As List(Of String)
        Dim oAddress As ServerAddressStruct

        If pAddress.Contains(";"c) Then
            oAddressList = pAddress.Split(";"c).ToList
        ElseIf pAddress.Contains(":"c) Then
            oAddressList = pAddress.Split(":"c).ToList
        Else
            oAddressList = New List(Of String) From {pAddress, Constants.DEFAULT_SERVICE_PORT}
        End If

        oAddress.Host = oAddressList.First()
        oAddress.Port = oAddressList.Item(1)

        Return oAddress
    End Function
End Class
