Example #1
0
        public Archivo(string pathArchivo)
        {
            this.Nombre = Path.GetFileName(pathArchivo);
            this.Clases = new Dictionary <string, Clase>();

            this.archivoOriginal = File.ReadAllText(pathArchivo, Encoding.GetEncoding(1252));
            this.LimpiarArchivo();

            this.lineas = this.archivo.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)
                          .Select(x => x.Trim())
                          .Where(x => !string.IsNullOrWhiteSpace(x))
                          .ToList();

            string linea;

            while (this.lineas.Count > 0)
            {
                linea = this.lineas[0];
                if (linea.StartsWith("class ") || linea.Contains(" class "))
                {
                    var clase = new Clase(this);
                    clase.Procesar(this.lineas);
                    this.Clases.Add(clase.Nombre, clase);
                }
                this.lineas.RemoveAt(0);
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Clase  clase  = (Clase)this.listBox2.SelectedItem;
            Metodo metodo = (Metodo)this.listBox1.SelectedItem;

            if (clase != null && metodo != null)
            {
                string fileName  = "informe.html";
                string textToAdd =
                    "<html>" +
                    "<head>" +
                    "<style>" +
                    // "body {background-color: #8cb8ff;}" +
                    "h1 {font-weight: bold; text-decoration: underline;}" +
                    "h3 {font-weight: bold;}" +
                    // "p {color: white;}" +
                    "</style>" +
                    "</head>" +
                    "<body>" +
                    "<h1>Archivo: " + clase.Nombre + "</h1>" +
                    "<h1>Metodo: " + metodo.ToString() + "</h1>" +
                    "<h3>Lineas con comentarios:</h3> <p>" + this.lblComentarios.Text + "</p>" +
                    "<h3>Complejidad ciclomatica:</h3> <p>" + this.lblCiclomatica.Text + "</p>" +
                    "<h3>Fan In:</h3> <p>" + this.lblFanIn.Text + "</p>" +
                    "<h3>Fan Out:</h3> <p>" + this.lblFanOut.Text + "</p>" +
                    "<h3>Longitud:</h3> <p>" + this.lblLongitud.Text + "</p>" +
                    "<h3>Volumen:</h3> <p>" + this.lblVolumen.Text + "</p>" +
                    "<h3>Operadores:</h3> <p>" + this.lblOperadores.Text + "</p>" +
                    "</body>" +
                    "</html>";

                using (StreamWriter writer = new StreamWriter(fileName, false))
                {
                    writer.Write(textToAdd);
                }
                System.Diagnostics.Process.Start(fileName);
                // MessageBox.Show("Informe generado correctamente", "Informe");
            }
            else
            {
                MessageBox.Show("Eliga una clase y método primero", "Error");
            }
        }
Example #3
0
 public Metodo(Clase clase)
 {
     this.clase = clase;
 }