Esempio n. 1
0
        public void Write(AssemblyStatistic[] statistics, TimeSpan time)
        {
            var outputDirectory = !this.OutputDirectory.IsNullOrEmpty()
                ? this.OutputDirectory
                : statistics[0].AssemblyData.File.DirectoryName;

            foreach (var statistic in statistics) {
                this.WriteStatistic(outputDirectory, statistic);
            }

            string summaryFile = Path.Combine(outputDirectory, "diet.summary");

            using (var writer = new StreamWriter(summaryFile)) {
                writer.WriteLine("Total assemblies: {0}.", statistics.Length);
                writer.WriteLine();

                var table = new ConsoleTable();
                table.SetHeaders(new[] { "Assembly", "Unused", "Ignored*" });

                this.AddPartitionSummary(table, "Roots", statistics.Where(s => s.InspectedAsRoot));
                table.AppendRow(new[] { string.Empty, string.Empty, string.Empty });
                this.AddPartitionSummary(table, "Other", statistics.Where(s => !s.InspectedAsRoot));

                writer.Write(table.ToString());
                writer.WriteLine("  * ignored code was probably code-generated");

                writer.WriteLine();
                writer.WriteLine("Analysed in {0}.", time);
            }
        }
Esempio n. 2
0
        private void AddPartitionSummary(ConsoleTable table, string title, IEnumerable<AssemblyStatistic> statistics)
        {
            table.AppendRow(new[] { title, string.Empty, string.Empty });

            var rows = from statistic in statistics
                       let name = statistic.AssemblyData.Name
                       orderby name
                       select new[] {
                           "  " + name, FormatRatio(statistic.UnusedMemberRatio), FormatRatio(statistic.IgnoredMemberRatio)
                       };

            rows.ForEach(table.AppendRow);
        }
Esempio n. 3
0
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		static void Main()
		{
			SQLiteClient db;
			SQLiteResultSet results;

			Console.WriteLine("Basic test app for SQLite.NET. Enter a single line sql query and it will be run against the database.\r\n");

			Console.WriteLine("Opening database 'test.db'...\r\n");
			
			try {
				// Open database
				db = new SQLiteClient("test.db");

			} catch (SQLiteException e) {
				Console.WriteLine("Fatal error: {0}", e.Message);
				Console.ReadLine();
				return;
			}

			Console.WriteLine("Available tables:");

			ArrayList tables = db.GetColumn("SELECT name FROM sqlite_master WHERE type = 'table'");

			foreach (string tableName in tables) {
				Console.WriteLine("\t" + tableName);
			}

			// Main loop
			while (true) {
				Console.Write("SQL> ");
				string input = Console.ReadLine();

				if (input == null || input.Trim() == "") {
					continue;
				}

				if (input == ".quit") {
					return;
				}

				try {
					results = db.Execute(input);

					ConsoleTable table = new ConsoleTable();
					table.SetHeaders(results.ColumnNames);

					// Loop through the results and display them
					foreach (ArrayList arr in results.Rows) {
						table.AppendRow(arr);
					}

					while (results.IsMoreData) {
						Hashtable foo = results.GetRowHash();
						foo.GetType();
					}

					Console.WriteLine(table.ToString());

				} catch (SQLiteException e) {
					Console.WriteLine(e.Message);
				}
			}
		}