public static bool TryParse(string address, out Hostname hostname) { hostname = null; RoutingHostName routingHostName; if (RoutingHostName.TryParse(address, out routingHostName)) { hostname = new Hostname(routingHostName); return(true); } return(false); }
private void ParseAndValidate(string settings) { EncryptionType?encryptionType = null; string[] array = settings.Split(new char[] { ':' }); if (array.Length < 2 || array.Length > 3) { throw new FormatException(DataStrings.ExceptionProtocolConnectionSettingsInvalidFormat(settings)); } Hostname hostname; if (!Hostname.TryParse(array[0], out hostname)) { throw new FormatException(DataStrings.ExceptionProtocolConnectionSettingsInvalidHostname(settings)); } int num; if (!int.TryParse(array[1], out num) || num < 0 || num > 65535) { throw new FormatException(DataStrings.ExceptionProtocolConnectionSettingsInvalidPort(settings, 0, 65535)); } if (array.Length > 2) { try { encryptionType = new EncryptionType?((EncryptionType)Enum.Parse(typeof(EncryptionType), array[2], true)); } catch (ArgumentException) { throw new FormatException(DataStrings.ExceptionProtocolConnectionSettingsInvalidEncryptionType(settings)); } } this.hostname = hostname; this.port = num; this.encryptionType = encryptionType; }
public override bool Equals(object comparand) { Hostname hostname = comparand as Hostname; return(hostname != null && this.Equals(hostname)); }
public bool Equals(Hostname rhs) { return(rhs != null && this.routingHostName.Equals(rhs.routingHostName)); }
public ProtocolConnectionSettings(Hostname hostname, int port, EncryptionType?encryptionType) { this.hostname = hostname; this.port = port; this.encryptionType = encryptionType; }