/// <summary>
        /// Parses a string into a connection object.
        /// </summary>
        /// <param name="text">The specified connection string.</param>
        /// <returns>Returns the connection object.</returns>
        public static InsteonConnection Parse(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException();
            }

            Regex connectionPattern = new Regex(@"\s*(?<type>[^: ]+)\s*:\s*(?<value>[^, ]+)\s*(,\s*(?<name>[^,]+)\s*)?(,\s*(?<address>[^, ]+))?");
            Match m = connectionPattern.Match(text);

            if (!m.Success)
            {
                throw new FormatException();
            }

            string type    = m.Groups["type"].ToString().Trim();
            string value   = m.Groups["value"].ToString().Trim();
            string name    = m.Groups["name"].ToString().Trim();
            string address = m.Groups["address"].ToString().Trim();

            if (string.IsNullOrEmpty(type) || string.IsNullOrEmpty(value))
            {
                throw new FormatException();
            }

            type = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(type);

            InsteonConnectionType rtype    = (InsteonConnectionType)System.Enum.Parse(typeof(InsteonConnectionType), type);
            InsteonAddress        raddress = !string.IsNullOrEmpty(address) ? InsteonAddress.Parse(address) : new InsteonAddress();

            return(new InsteonConnection(rtype, value, name, raddress));
        }
        /// <summary>
        /// Initializes a new connection instance.
        /// </summary>
        /// <param name="type">Type type of connection.</param>
        /// <param name="value">The connection value.</param>
        /// <param name="name">The display name for the connection.</param>
        /// <param name="address">The INSTEON address of the controller device.</param>
        public InsteonConnection(InsteonConnectionType type, string value, string name, InsteonAddress address)
        {
            if (string.IsNullOrEmpty(value))
                throw new ArgumentNullException();

            this.Type = type;
            this.Value = value.Trim();
            if (!string.IsNullOrEmpty(name) && name.Trim().Length > 0)
                this.Name = name.Trim();
            else
                this.Name = value;
            this.Address = address;
        }
        /// <summary>
        /// Initializes a new connection instance.
        /// </summary>
        /// <param name="type">Type type of connection.</param>
        /// <param name="value">The connection value.</param>
        /// <param name="name">The display name for the connection.</param>
        /// <param name="address">The INSTEON address of the controller device.</param>
        public InsteonConnection(InsteonConnectionType type, string value, string name, InsteonAddress address)
        {
            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentNullException();
            }

            Type  = type;
            Value = value.Trim();
            if (!string.IsNullOrEmpty(name) && name.Trim().Length > 0)
            {
                Name = name.Trim();
            }
            else
            {
                Name = value;
            }
            Address = address;
        }
 /// <summary>
 /// Initializes a new connection instance.
 /// </summary>
 /// <param name="type">Type type of connection.</param>
 /// <param name="value">The connection value.</param>
 public InsteonConnection(InsteonConnectionType type, string value)
 : this(type, value, value, new InsteonAddress())
 {
 }
 /// <summary>
 /// Initializes a new connection instance.
 /// </summary>
 /// <param name="type">Type type of connection.</param>
 /// <param name="value">The connection value.</param>
 public InsteonConnection(InsteonConnectionType type, string value)
     : this(type, value, value, new InsteonAddress())
 {
 }