/*- * See the file LICENSE for redistribution information. * * Copyright (c) 2009 Oracle. All rights reserved. * */ using System; using System.Collections.Generic; using System.Text; namespace BerkeleyDB { /// /// A class representing the address of a replication site used by Berkeley /// DB HA. /// public class ReplicationHostAddress { /// /// The site's host identification string, generally a TCP/IP host name. /// public string Host; /// /// The port number on which the site is receiving. /// public uint Port; /// /// Instantiate a new, empty address /// public ReplicationHostAddress() { } /// /// Instantiate a new address, parsing the host and port from the given /// string /// /// A string in host:port format public ReplicationHostAddress(string HostAndPort) { int sep = HostAndPort.IndexOf(':'); if (sep == -1) throw new ArgumentException( "Hostname and port must be separated by a colon."); if (sep == 0) throw new ArgumentException( "Invalid hostname."); try { Port = UInt32.Parse(HostAndPort.Substring(sep + 1)); } catch { throw new ArgumentException("Invalid port number."); } Host = HostAndPort.Substring(0, sep); } /// /// Instantiate a new address /// /// The site's host identification string /// /// The port number on which the site is receiving. /// public ReplicationHostAddress(string Host, uint Port) { this.Host = Host; this.Port = Port; } } }