This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Program.cs
54 lines (45 loc) · 2.06 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.IO;
using POCOGenerator;
namespace ConsoleColorDemo
{
class Program
{
static void Main()
{
Console.ForegroundColor = ConsoleColor.Red;
IGenerator generator = GeneratorFactory.GetConsoleColorGenerator();
try { generator.Settings.Connection.ConnectionString = File.ReadAllText("ConnectionString.txt"); } catch { }
if (string.IsNullOrEmpty(generator.Settings.Connection.ConnectionString))
generator.Settings.Connection.ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=AdventureWorks2014;Integrated Security=True";
generator.Settings.DatabaseObjects.Tables.IncludeAll = true;
generator.Settings.POCO.CommentsWithoutNull = true;
generator.Settings.ClassName.IncludeSchema = true;
generator.Settings.ClassName.SchemaSeparator = "_";
generator.Settings.ClassName.IgnoreDboSchema = true;
generator.Settings.EFAnnotations.Enable = true;
GeneratorResults results = generator.Generate();
PrintError(results, generator.Error);
Console.WriteLine();
Console.WriteLine("Press any key to continue . . .");
Console.ReadKey(true);
}
private static void PrintError(GeneratorResults results, Exception Error)
{
bool isError = (results & GeneratorResults.Error) == GeneratorResults.Error;
bool isWarning = (results & GeneratorResults.Warning) == GeneratorResults.Warning;
if (results != GeneratorResults.None)
Console.WriteLine();
if (isError)
Console.WriteLine("Error Result: {0}", results);
else if (isWarning)
Console.WriteLine("Warning Result: {0}", results);
if (Error != null)
{
Console.WriteLine("Error: {0}", Error.Message);
Console.WriteLine("Error Stack Trace:");
Console.WriteLine(Error.StackTrace);
}
}
}
}