private void _AssignValue(string item)
{
//extract the values
Match pair = Regex.Match(item ?? string.Empty, "^(?<key>[^=]+)=(?<value>.*)$");
if (!pair.Success) { return; }
//otherwise, get the values
string key = pair.Groups["key"].Value.Trim();
if (string.IsNullOrEmpty(key)) { return; }
//get the value and undo escaping the ; values
string value = pair.Groups["value"].Value.Replace(@"\;", ";");
//depending on the value, set the property
if (key.Equals("username", StringComparison.OrdinalIgnoreCase)) {
this.Username = value.Trim();
}
else if (key.Equals("password", StringComparison.OrdinalIgnoreCase)) {
this.Password = value;
}
else if (key.Equals("database", StringComparison.OrdinalIgnoreCase)) {
this.Database = value.Trim();
}
else if (key.Equals("host", StringComparison.OrdinalIgnoreCase)) {
this.Host = value.Trim();
}
else if (key.Equals("autoconnect")) {
bool auto = true;
bool.TryParse(value, out auto);
this.AutoConnect = auto;
}
else if (key.Equals("port")) {
int port = 0;
int.TryParse(value, out port);
this.Port = port;
}
}