private static void Guarda(CampoNodoRuteable elCampoNodo, int elNúmero, StreamWriter elEscritor) { // Crea el texto. string texto = string.Format("{0},{1}", elCampoNodo.IndiceDeCoordenadas, elCampoNodo.IdentificadorGlobal); if (elCampoNodo.EsExterno) { texto += ",1"; } else { texto += ",0"; } Guarda(elCampoNodo, elNúmero, texto, elEscritor); }
private static CampoNodoRuteable LeeCampoNodo( string elIdentificador, string elTexto) { // Verifica que tenemos 3 partes. string[] partes = elTexto.Split(','); if (partes.Length != 3) { throw new ArgumentException(string.Format("El texto del campo de nodo debe tener tres partes: {0}", elTexto)); } // Extrae los parámetros del nodo. int indice = Convert.ToInt32(partes[0]); int identificador = Convert.ToInt32(partes[1]); int esExternoComoNúmero = Convert.ToInt32(partes[2]); bool esExterno; switch (esExternoComoNúmero) { case 0: esExterno = false; break; case 1: esExterno = true; break; default: throw new ArgumentException(string.Format("El tercer parámetro debe ser 0 ó 1: {0}", elTexto)); } // Crea el nodo. var nodo = new CampoNodoRuteable( elIdentificador, indice, identificador, esExterno); return(nodo); }