public void Test() { var cfg = new CodeRunnerConfig(); var configOptions = new DefaultConfigurationOptions(); configOptions.EnumNamespace = "The.Enum.Namespace"; var enumList = new List<EnumDescriptor>(); enumList.Add(new EnumDescriptor { TableName = "TransactionLineType", NameField = "Label", ValueField = "ID" }); configOptions.Enums = enumList; configOptions.ConnectionString = "user id=sa;password=anja8247;server=(local);database=Lars"; configOptions.OutputPath = @"C:\dev"; configOptions.EnumOutputPath = @"C:\dev"; cfg.DbProvider = new SqlServerProvider(new DbHelper(configOptions.ConnectionString)); cfg.Generator = new ConfigurableActiveRecordGenerator(configOptions); cfg.NameProvider = new NameProvider(); cfg.Options = configOptions; cfg.Writer = (s) => { return Console.Out; }; var codeRunner = new CodeRunnerImpl(cfg); codeRunner.Execute(); }
/// <summary> /// Responsible for executing a <see cref="ICodeRunner"/> implementation for /// each of the configuration sections specified in the hyperactive config file. /// </summary> public void Run() { var configParser = new DefaultConfigParser(); var configs = configParser.ParseXml(_contentsOfConfigFile); foreach (IConfigurationOptions config in configs) { EnsureOutputPath(config); EnsureEnumOutputPath(config); var assemblyDirectory = String.IsNullOrEmpty(config.AssemblyDirectory) ? _assemblyDirectory : config.AssemblyDirectory; Log.WriteLine("AssemblyDirectory: {0}", assemblyDirectory); var ioc = new Ioc(assemblyDirectory, config.Components, true); var cfg = new CodeRunnerConfig(); cfg.DbProvider = ioc.Get<IDbProvider>(); if (cfg.DbProvider == null) { if (String.IsNullOrEmpty(config.ConnectionString)) { Log.WriteLine("It seems as though no DbProvider component was specified in the config and no connectionstring was specified."); Log.WriteLine("Either define <add key=\"connectionstring\" value=\"your connection string\" /> at the root of the config node"); Log.WriteLine("or define a DbProvider component in the components section."); continue; } cfg.DbProvider = new SqlServerProvider(new DbHelper(config.ConnectionString)); } Log.WriteLine("DbProvider -> {0}", cfg.DbProvider.GetType().Name); cfg.Generator = ioc.Get<ActiveRecordGenerator>() ?? new ConfigurableActiveRecordGenerator(config); if (cfg.Generator.ConfigOptions == null) { cfg.Generator.ConfigOptions = config; } Log.WriteLine("Generator -> {0}", cfg.Generator.GetType().Name); cfg.NameProvider = InitializeNameProvider(config, ioc); cfg.Generator.NameProvider = cfg.NameProvider; cfg.Options = config; cfg.Writer = (path) => { return new StreamWriter(path, false); }; var codeRunner = new CodeRunnerImpl(cfg); codeRunner.VerboseLogging = true; codeRunner.Execute(); } }
public CodeRunnerImpl(CodeRunnerConfig codeRunnerConfig) { _codeRunnerConfig = codeRunnerConfig; _options = _codeRunnerConfig.Options; }