public void SetItem(string value, ConnectionStringPart index) { Init(); lock (m_Parts) { if (string.IsNullOrEmpty(m_ConnectionString)) { return; } Regex rExp = GetRegEx(index); Match m = rExp.Match(m_ConnectionString); if (m.Success) { m_ConnectionString = rExp.Replace(m_ConnectionString, string.Format("{0}={1}", m_Parts[index].Name, value)); } else { if (!m_ConnectionString.Trim().EndsWith(";")) { m_ConnectionString += ";"; } m_ConnectionString += string.Format("{0}={1};", m_Parts[index].Name, value); } } }
public string Item(ConnectionStringPart index) { Init(); lock (m_Parts) { if (string.IsNullOrEmpty(m_ConnectionString)) { return(""); } Regex rExp = GetRegEx(index); Match m = rExp.Match(m_ConnectionString); if (m.Success) { return(m.Value); } else { return(""); } } }
private Regex GetRegEx(ConnectionStringPart index) { return(new Regex(string.Format(m_RegExpTemplate, m_Parts[index].Mask, index.ToString()))); }