DesperateDevs.CodeGeneration.CodeGenerator.CodeGenerator CodeGeneratorFromPreferences(Preferences preferences) { ICodeGenerationPlugin[] instances = LoadFromPlugins(preferences); CodeGeneratorConfig andConfigure = preferences.CreateAndConfigure <CodeGeneratorConfig>(); IPreProcessor[] enabledInstancesOf1 = CodeGeneratorUtil.GetEnabledInstancesOf <IPreProcessor>(instances, andConfigure.preProcessors); IDataProvider[] enabledInstancesOf2 = CodeGeneratorUtil.GetEnabledInstancesOf <IDataProvider>(instances, andConfigure.dataProviders); ICodeGenerator[] enabledInstancesOf3 = CodeGeneratorUtil.GetEnabledInstancesOf <ICodeGenerator>(instances, andConfigure.codeGenerators); IPostProcessor[] enabledInstancesOf4 = CodeGeneratorUtil.GetEnabledInstancesOf <IPostProcessor>(instances, andConfigure.postProcessors); configure((ICodeGenerationPlugin[])enabledInstancesOf1, preferences); configure((ICodeGenerationPlugin[])enabledInstancesOf2, preferences); configure((ICodeGenerationPlugin[])enabledInstancesOf3, preferences); configure((ICodeGenerationPlugin[])enabledInstancesOf4, preferences); bool trackHooks = true; if (preferences.HasKey("Jenny.TrackHooks")) { trackHooks = preferences["Jenny.TrackHooks"] == "true"; } return(new DesperateDevs.CodeGeneration.CodeGenerator.CodeGenerator(enabledInstancesOf1, enabledInstancesOf2, enabledInstancesOf3, enabledInstancesOf4, trackHooks)); }
protected override void run() { var config = new CodeGeneratorConfig(); config.Configure(_preferences); var cliConfig = new CLIConfig(); cliConfig.Configure(_preferences); forceAddKeys(config.defaultProperties, _preferences); forceAddKeys(cliConfig.defaultProperties, _preferences); Type[] types = null; try { types = CodeGeneratorUtil.LoadTypesFromPlugins(_preferences); // A test to check if all types can be resolved and instantiated. CodeGeneratorUtil.GetEnabledInstancesOf <ICodeGeneratorDataProvider>(types, config.dataProviders); CodeGeneratorUtil.GetEnabledInstancesOf <ICodeGenerator>(types, config.codeGenerators); CodeGeneratorUtil.GetEnabledInstancesOf <ICodeGenFilePostProcessor>(types, config.postProcessors); } catch (Exception ex) { throw ex; } var askedRemoveKeys = new HashSet <string>(); var askedAddKeys = new HashSet <string>(); while (fix(askedRemoveKeys, askedAddKeys, types, config, cliConfig, _preferences)) { } }