Exemplo n.º 1
0
 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);
         }
     }
 }
Exemplo n.º 2
0
 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("");
         }
     }
 }
Exemplo n.º 3
0
 private Regex GetRegEx(ConnectionStringPart index)
 {
     return(new Regex(string.Format(m_RegExpTemplate, m_Parts[index].Mask, index.ToString())));
 }