/// <summary> /// Reset all elements. /// </summary> public void Reset() { service = string.Empty; database = string.Empty; userid = string.Empty; password = string.Empty; isIntegratedSecurity = false; OtherPairs.Clear(); }
public string GetOtherPair(string key) { key = key.ToLower(); if (!OtherPairs.ContainsKey(key)) { return(string.Empty); } return(OtherPairs[key]); }
public void SetOtherPair(string key, string value) { key = key.ToLower(); if (OtherPairs.ContainsKey(key)) { OtherPairs[key] = value; } else { OtherPairs.Add(key, value); } }
/// <summary> /// Get or set the KEY=VALUE component of the connection string /// </summary> /// <param name="index"></param> /// <returns></returns> public string this[string index] { get { index = index.ToLower(); switch (index) { case "server": case "data source": return(this.Service); case "integrated security": return(this.IsIntegratedSecurity ? "true" : "false"); case "database": case "initial catalog": return(this.database); case "userid": // this is not a real key! case "uid": case "user id": return(this.Userid); case "pwd": case "password": return(this.Password); default: if (OtherPairs.ContainsKey(index)) { return(OtherPairs[index]); } return(""); } } set { index = index.ToLower(); switch (index) { case "server": case "data source": this.Service = value; break; case "integrated security": this.IsIntegratedSecurity = DataConvert.ToBoolean(value); break; case "database": case "initial catalog": this.database = value; break; case "userid": // this is not a real key! case "uid": case "user id": this.Userid = value; break; case "pwd": case "password": this.Password = value; break; default: if (OtherPairs.ContainsKey(index)) { OtherPairs[index] = value; } else { OtherPairs.Add(index, value); } break; } } }