public static bool TryParse(String candidate, bool allowPartialIP, bool allowName, out ComparableAddress address) { address = null; if (string.IsNullOrEmpty(candidate)) { return(false); } IPAddress ipAddress; PartialIP pip; if (IPAddress.TryParse(candidate, out ipAddress)) { address = new ComparableAddress(ipAddress.GetAddressBytes()); return(true); } else if (allowPartialIP && PartialIP.TryParse(candidate, out pip)) { address = new ComparableAddress(pip); return(true); } else if (allowName) { address = new ComparableAddress(candidate); return(true); } return(false); }
public static bool TryParse(String candidate, out PartialIP ip) { ip = null; if (!CouldBeValidPartialIp(candidate)) return false; try { ip = Parse(candidate); return true; } catch { return false; } }
public static bool TryParse(String candidate, out PartialIP ip) { ip = null; if (!CouldBeValidPartialIp(candidate)) { return(false); } try { ip = Parse(candidate); return(true); } catch { return(false); } }
private ComparableAddress(PartialIP pip) { partialIP = pip; }