/// <summary> /// Convierte una colección de registros (fieles al txt) mediante un filtro, a una representación de cada parte del flujo. /// </summary> /// <remarks> /// Registro de versiones: /// /// 1.0 02/03/2015 Marcos Abraham Hernández Bravo (Ada Ltda.): versión inicial. /// </remarks> /// <param name="registros">Colección de registros en línea(fieles al txt).</param> /// <param name="filtro">Filtro para excluir elementos. <value>true</value> para incluir, <value>false</value> para excluir.</param> /// <returns>Representación completa del flujo</returns> public MetodoTO Convertir(IList <RegistroInLineTO> registros, Func <RegistroInLineTO, bool> filtro = null) { MetodoTO retorno = new MetodoTO(); int indiceInicio = 0; retorno = CargarArbol(retorno, ref indiceInicio, registros, filtro); return(retorno); }
/// <summary> /// Carga una colección de registros (fieles al txt) mediante un filtro, a una representación de cada parte del flujo. /// </summary> /// <remarks> /// Registro de versiones: /// /// 1.0 02/03/2015 Marcos Abraham Hernández Bravo (Ada Ltda.): versión inicial. /// </remarks> /// <param name="retorno">Representación completa del flujo, para cargar los datos leídos.</param> /// <param name="x">Fila inicial a leer. Luego se continúa hasta el final.</param> /// <param name="registros">Registros fieles el archivo plano (Origen de la información).</param> /// <param name="filtro">Filtro para excluir elementos. <value>true</value> para incluir, <value>false</value> para excluir.</param> /// <returns>Representación completa del flujo</returns> private MetodoTO CargarArbol(MetodoTO retorno, ref int x, IList <RegistroInLineTO> registros, Func <RegistroInLineTO, bool> filtro = null) { while (x < registros.Count) { RegistroInLineTO registro = registros[x]; if (filtro == null || (filtro != null && filtro(registro))) { if (registro.Tipo == "Inicio") { if (retorno.Nombre != null) { retorno.Llamadas.Add(CargarArbol(new MetodoTO(), ref x, registros)); } else { retorno.Nombre = registro.Metodo; retorno.Clase = registro.Clase; retorno.MethodGUID = registro.MethodGUID; retorno.Fecha = registro.Fecha; } } else if (registro.Tipo == "Retorno") { retorno.Retorno = new RetornoTO() { Fecha = registro.Fecha, Tipo = registro.TipoVariable, Valor = registro.ValorVariable }; return(retorno); } else if (registro.Tipo == "Excepcion") { retorno.Excepcion = new ExcepcionTO() { Data = registro.Data, Mensaje = registro.Mensaje, StackTrace = registro.StackTrace, Tipo = registro.NombreVariable, }; } else if (registro.Tipo == "Parametro") { retorno.Parametros.Add(new ParametroTO() { Nombre = registro.NombreVariable, Tipo = registro.TipoVariable, Valor = registro.ValorVariable }); } } x++; } return(null); }
public MetodoTO ConvertirMetodo(IList <RegistroInLineTO> registros, Func <RegistroInLineTO, bool> filtro = null) { int fila = 0; MetodoTO retorno = CargarArbol(new MetodoTO(), ref fila, registros, filtro); if (registros.Count > 0) { retorno.Hilo = new HiloTO() { ThreadGUID = registros[0].ThreadGUID }; } return(retorno); }
public void CrearDiagrama() { MetodoTO metodoInicial = Sesion.HiloActual.Ejecuciones[0]; Clase usuario = diagramaSecuencia.AgregarClase("Usuario", true); ClasesCreadas.Add(metodoInicial.Clase, diagramaSecuencia.AgregarClase(metodoInicial.Clase)); diagramaSecuencia.AgregarInicioLlamada(metodoInicial.Nombre, usuario.Linea, ClasesCreadas[metodoInicial.Clase].Linea, metodoInicial.MethodGUID); for (int i = 0; i < Sesion.HiloActual.Ejecuciones.Count; i++) { MostrarMetodo(Sesion.HiloActual.Ejecuciones[i], diagramaSecuencia, true); } diagramaSecuencia.AgregarRetornoLlamada(ClasesCreadas[metodoInicial.Clase].Linea, usuario.Linea, metodoInicial.Excepcion != null, metodoInicial.Retorno.Valor.ToString() == "<Void>", metodoInicial.MethodGUID); }
public void MostrarMetodo(MetodoTO metodo, DiagramaSecuencia diagramaSecuencia, bool agregarDefinicion) { if (agregarDefinicion) { if (!ClasesCreadas.ContainsKey(metodo.Clase)) { ClasesCreadas.Add(metodo.Clase, diagramaSecuencia.AgregarClase(metodo.Clase)); } } foreach (MetodoTO llamada in metodo.Llamadas) { if (!ClasesCreadas.ContainsKey(llamada.Clase)) { ClasesCreadas.Add(llamada.Clase, diagramaSecuencia.AgregarClase(llamada.Clase)); } diagramaSecuencia.AgregarInicioLlamada(llamada.Nombre, ClasesCreadas[metodo.Clase].Linea, ClasesCreadas[llamada.Clase].Linea, llamada.MethodGUID); MostrarMetodo(llamada, diagramaSecuencia, false); diagramaSecuencia.AgregarRetornoLlamada(ClasesCreadas[llamada.Clase].Linea, ClasesCreadas[metodo.Clase].Linea, llamada.Excepcion != null, (llamada.Retorno.Valor.ToString() == "<Void>" || string.IsNullOrWhiteSpace(llamada.Retorno.Valor.ToString())), llamada.MethodGUID); } }
/// <summary> /// Carga una colección de registros (fieles al txt) mediante un filtro, a una representación de cada parte del flujo. /// </summary> /// <remarks> /// Registro de versiones: /// /// 1.0 02/03/2015 Marcos Abraham Hernández Bravo (Ada Ltda.): versión inicial. /// </remarks> /// <param name="retorno">Representación completa del flujo, para cargar los datos leídos.</param> /// <param name="indiceInicio">Fila inicial a leer. Luego se continúa hasta el final.</param> /// <param name="registros">Registros fieles el archivo plano (Origen de la información).</param> /// <param name="filtro">Filtro para excluir elementos. <value>true</value> para incluir, <value>false</value> para excluir.</param> /// <returns>Representación completa del flujo</returns> private MetodoTO CargarArbol(MetodoTO retorno, ref int indiceInicio, IList <RegistroInLineTO> registros, Func <RegistroInLineTO, bool> filtro = null) { for (int indice = indiceInicio; indice < registros.Count; indice++) { RegistroInLineTO registro = registros[indice]; if (filtro == null || (filtro != null && filtro(registro))) { if (registro.Tipo == Tipo.Inicio) { if (retorno.Inicio != null) { retorno.Llamadas.Add(CargarArbol(new MetodoTO(), ref indiceInicio, registros)); } else { retorno.Inicio = new InicioTO() { Namespace = registro.Namespace, Clase = registro.Clase, Llamada = registro.Correlativo, Fecha = registro.Fecha, MethodGUID = registro.MethodGUID, Metodo = registro.Metodo, ThreadGUID = registro.ThreadGUID }; retorno.Namespace = retorno.Inicio.Namespace; retorno.Clase = retorno.Inicio.Clase; retorno.Llamada = retorno.Inicio.Llamada; retorno.Fecha = retorno.Inicio.Fecha; retorno.MethodGUID = retorno.Inicio.MethodGUID; retorno.ThreadGUID = retorno.Inicio.ThreadGUID; retorno.Metodo = retorno.Inicio.Metodo; } } else if (registro.Tipo == Tipo.Variable) { retorno.Variables.Add(new VariableTO() { Namespace = retorno.Inicio.Namespace, Clase = retorno.Inicio.Clase, Llamada = retorno.Inicio.Llamada, Fecha = registro.Fecha, MethodGUID = retorno.Inicio.MethodGUID, ThreadGUID = retorno.Inicio.ThreadGUID, Nombre = registro.NombreVariable, Valor = registro.ValorVariable }); } else if (registro.Tipo == Tipo.Retorno) { retorno.Retorno = new RetornoTO() { Namespace = retorno.Inicio.Namespace, Clase = retorno.Inicio.Clase, Llamada = retorno.Inicio.Llamada, Fecha = registro.Fecha, MethodGUID = retorno.Inicio.MethodGUID, ThreadGUID = retorno.Inicio.ThreadGUID, Valor = registro.ValorVariable }; return(retorno); } else if (registro.Tipo == Tipo.Excepcion) { retorno.Excepciones.Add(new ExcepcionTO() { Namespace = retorno.Inicio.Namespace, Clase = retorno.Inicio.Clase, Llamada = retorno.Inicio.Llamada, Fecha = registro.Fecha, MethodGUID = retorno.Inicio.MethodGUID, ThreadGUID = retorno.Inicio.ThreadGUID, Data = registro.Data, Mensaje = registro.Mensaje, StackTrace = registro.StackTrace, Tipo = registro.NombreVariable, }); } else if (registro.Tipo == Tipo.Mensaje) { retorno.Mensajes.Add(new MensajeTO() { Namespace = retorno.Inicio.Namespace, Clase = retorno.Inicio.Clase, Llamada = retorno.Inicio.Llamada, Fecha = registro.Fecha, Nivel = registro.Nivel, MethodGUID = retorno.Inicio.MethodGUID, ThreadGUID = retorno.Inicio.ThreadGUID, Mensaje = registro.Mensaje }); } else if (registro.Tipo == Tipo.Parametro) { retorno.Parametros.Add(new ParametroTO() { Namespace = retorno.Inicio.Namespace, Clase = retorno.Inicio.Clase, Llamada = retorno.Inicio.Llamada, Fecha = registro.Fecha, MethodGUID = retorno.Inicio.MethodGUID, ThreadGUID = retorno.Inicio.ThreadGUID, Nombre = registro.NombreVariable, Valor = registro.ValorVariable }); } } } return(null); }