private static string CreateHostStringHelper(string str, ushort idx, ushort end, ref Flags flags, ref string scopeId)
{
bool loopback = false;
string host;
switch (flags & Flags.HostTypeMask)
{
case Flags.DnsHostType:
host = DomainNameHelper.ParseCanonicalName(str, idx, end, ref loopback);
break;
case Flags.IPv6HostType:
// The helper will return [...] string that is not suited for Dns.Resolve()
host = IPv6AddressHelper.ParseCanonicalName(str, idx, ref loopback, ref scopeId);
break;
case Flags.IPv4HostType:
host = IPv4AddressHelper.ParseCanonicalName(str, idx, end, ref loopback);
break;
case Flags.UncHostType:
host = UncNameHelper.ParseCanonicalName(str, idx, end, ref loopback);
break;
case Flags.BasicHostType:
if (StaticInFact(flags, Flags.DosPath))
{
host = string.Empty;
}
else
{
// This is for a registry-based authority, not relevant for known schemes
host = str.Substring(idx, end - idx);
}
// A empty host would count for a loopback
if (host.Length == 0)
{
loopback = true;
}
//there will be no port
break;
case Flags.UnknownHostType:
//means the host is *not expected* for this uri type
host = string.Empty;
break;
default:
throw GetException(ParsingError.BadHostName);
}
if (loopback)
{
flags |= Flags.LoopbackHost;
}
return host;
}