//Lee del fichero de configuración private void ParseConf() { //Archivo a leer if (File.Exists(Constants.ConfigFileDatabases)) { StreamReader conFile = File.OpenText(Constants.ConfigFileDatabases); string line = conFile.ReadLine(); //Voy leyendo línea por línea while (line != null) { int i = 0; bool param = true, secondParam = false, thirdParam = false; string parameter = "", valor = "", usuario = "", contrasenia = ""; /* * * database_type=database_name; * * Ejemplo: * mongodb*empleados|pepe*contraseniaEncriptada; * */ //Leemos el parámetro while (line[i] != ';') { //Ignoramos el igual y lo usamos como marca que separa el parámetro de su valor if (line[i] == '*') { param = false; if (secondParam) { thirdParam = true; } } else if (line[i] == '|') { secondParam = true; param = true; } else if (param && !secondParam && !thirdParam) { parameter += line[i]; } else if (!param && !secondParam && !thirdParam) { valor += line[i]; } else if (param && secondParam && !thirdParam) { usuario += line[i]; } else if (thirdParam) { contrasenia += line[i]; } i++; } if (usuario == "") { usuario = null; } if (contrasenia == "") { contrasenia = null; } else { contrasenia = Cripto.DecryptStringFromBytes(this._symmetric, Convert.FromBase64String(contrasenia)); } if (this._databasesPropias.ContainsKey(parameter)) { Tuple <string, string, string> tupla = new Tuple <string, string, string>(valor, usuario, contrasenia); this._databasesPropias[parameter].Add(tupla); } else { List <Tuple <string, string, string> > aux = new List <Tuple <string, string, string> >(); Tuple <string, string, string> tupla = new Tuple <string, string, string>(valor, usuario, contrasenia); aux.Add(tupla); this._databasesPropias.Add(parameter, aux); } line = conFile.ReadLine(); } conFile.Close(); } }