static void Execute(SchemaManagerOptions options) { var sm = new SchemaManager(options); string script = string.Empty; switch (_operation) { case Operation.Create: script = sm.Create(); break; case Operation.Update: script = sm.Update(); break; case Operation.Delete: script = sm.Drop(); break; default: script = sm.Create(); break; } if (options.Mode == SchemaManagerMode.Silent || _verbose) { Console.WriteLine(script); } }
static OptionSet RegisterOptions(SchemaManagerOptions options) { var os = new OptionSet(); os.Add("c:", c => options.ConfigFile = Path.GetFullPath(c)); os.Add("a:", a => options.MappingAssemblies = a.Split(';').Select(f => Path.GetFullPath(f)).ToList()); os.Add("d:", d => options.MappingDirectories = d.Split(';').Select(f => Path.GetFullPath(f)).ToList()); os.Add("m:", m => options.ModelAssemblies = m.Split(';').Select(f => Path.GetFullPath(f)).ToList()); os.Add("s", s => options.Mode = (s != null) ? SchemaManagerMode.Silent : SchemaManagerMode.Execute); os.Add("o:", o => _operation = (Operation)Enum.Parse(typeof(Operation), o)); os.Add("v", v => _verbose = (v != null)); os.Add("b", b => _debug = (b != null)); os.Add("L", L => _license = (L != null)); os.Add("h|?", h => _help = (h != null)); return(os); }
public void TestAssemlbyWithModelsCreate() { var options = new SchemaManagerOptions() { Mode = SchemaManagerMode.Execute, MappingAssemblies = new List <string>() { BaseDirectory + @"\TestData\TestAssemblyWithModels\bin\Debug\TestAssemblyWithModels.dll" }, ConfigFile = BaseDirectory + @"\TestData\hibernate.cfg.xml" }; var sm = new SchemaManager(options); sm.Create(); Assert.Pass(); }
static void Main(string[] args) { try { var options = new SchemaManagerOptions(); var os = RegisterOptions(options); if (args.Length == 0) { PrintNoArgs(); return; } os.Parse(args); if (_debug) { PrintOptions(options); } if (_license) { PrintResourceFile("nst.license.txt"); } else if (_help) { PrintResourceFile("nst.HelpCommand.txt"); } else { Execute(options); } } catch (Exception ex) { PrintError(ex); } }
static void PrintOptions(SchemaManagerOptions options) { Console.WriteLine(options.ConfigFile); if (options.MappingAssemblies != null) { foreach (var a in options.MappingAssemblies) { Console.WriteLine(a); } } if (options.MappingDirectories != null) { foreach (var d in options.MappingDirectories) { Console.WriteLine(d); } } if (options.ModelAssemblies != null) { foreach (var m in options.ModelAssemblies) { Console.WriteLine(m); } } Console.WriteLine("Embedded Resources"); var asm = Type.GetType("nst.Program").Assembly; foreach (var name in asm.GetManifestResourceNames()) { Console.WriteLine(name); } }