Пример #1
0
        public override void Run(string[] args)
        {
            if (assertProperties())
            {
                var properties = loadProperties();
                var config     = new CodeGeneratorConfig();
                config.Configure(properties);

                Type[] types = null;
                Dictionary <string, string> configurables = null;

                try {
                    types         = CodeGeneratorUtil.LoadTypesFromPlugins(properties);
                    configurables = CodeGeneratorUtil.GetConfigurables(
                        CodeGeneratorUtil.GetUsed <ICodeGeneratorDataProvider>(types, config.dataProviders),
                        CodeGeneratorUtil.GetUsed <ICodeGenerator>(types, config.codeGenerators),
                        CodeGeneratorUtil.GetUsed <ICodeGenFilePostProcessor>(types, config.postProcessors)
                        );
                } catch (Exception ex) {
                    fixKeys(null, config.defaultProperties, properties);
                    throw ex;
                }

                fixKeys(configurables, config.defaultProperties, properties);
                fixConfigurableKeys(configurables, properties);
                fixPlugins(types, config, properties);
            }
        }
Пример #2
0
        public override void Run(string[] args)
        {
            if (assertPreferences())
            {
                var preferences = loadPreferences();
                var config      = new CodeGeneratorConfig();
                config.Configure(preferences);

                fabl.Debug(config.ToString());

                Type[] types = null;
                Dictionary <string, string> configurables = null;

                try {
                    types         = CodeGeneratorUtil.LoadTypesFromPlugins(preferences);
                    configurables = CodeGeneratorUtil.GetConfigurables(
                        CodeGeneratorUtil.GetUsed <ICodeGeneratorDataProvider>(types, config.dataProviders),
                        CodeGeneratorUtil.GetUsed <ICodeGenerator>(types, config.codeGenerators),
                        CodeGeneratorUtil.GetUsed <ICodeGenFilePostProcessor>(types, config.postProcessors)
                        );
                } catch (Exception ex) {
                    printKeyStatus(config.defaultProperties.Keys.ToArray(), preferences);
                    throw ex;
                }

                var requiredKeys = config.defaultProperties.Merge(configurables).Keys.ToArray();

                printKeyStatus(requiredKeys, preferences);
                printPluginStatus(types, config);
            }
        }
Пример #3
0
 static Dictionary <string, string> getConfigurables(Type[] types, CodeGeneratorConfig config)
 {
     return(CodeGeneratorUtil.GetConfigurables(
                CodeGeneratorUtil.GetUsed <ICodeGeneratorDataProvider>(types, config.dataProviders),
                CodeGeneratorUtil.GetUsed <ICodeGenerator>(types, config.codeGenerators),
                CodeGeneratorUtil.GetUsed <ICodeGenFilePostProcessor>(types, config.postProcessors)
                ));
 }
Пример #4
0
 Dictionary <string, string> GetConfigurables()
 {
     return(CodeGeneratorUtil.GetConfigurables(
                CodeGeneratorUtil.GetUsed <ICodeGeneratorDataProvider>(mTypes, mCodeGeneratorConfig.DataProviders),
                CodeGeneratorUtil.GetUsed <ICodeGenerator>(mTypes, mCodeGeneratorConfig.CodeGenerators),
                CodeGeneratorUtil.GetUsed <ICodeGenFilePostProcessor>(mTypes, mCodeGeneratorConfig.PostProcessors)
                ));
 }
Пример #5
0
        static void status()
        {
            if (File.Exists(Preferences.configPath))
            {
                var fileContent = File.ReadAllText(Preferences.configPath);
                var properties  = new Properties(fileContent);
                var config      = new CodeGeneratorConfig(new Config(fileContent));

                _logger.Debug(config.ToString());

                Type[]   types            = null;
                string[] configurableKeys = null;

                try {
                    types            = CodeGeneratorUtil.LoadTypesFromCodeGeneratorAssemblies();
                    configurableKeys = getConfigurableKeys(
                        CodeGeneratorUtil.GetUsed <ICodeGeneratorDataProvider>(types, config.dataProviders),
                        CodeGeneratorUtil.GetUsed <ICodeGenerator>(types, config.codeGenerators),
                        CodeGeneratorUtil.GetUsed <ICodeGenFilePostProcessor>(types, config.postProcessors)
                        );
                } catch (Exception ex) {
                    foreach (var key in getUnusedKeys(properties))
                    {
                        _logger.Info("Unused key: " + key);
                    }

                    foreach (var key in getMissingKeys(properties))
                    {
                        _logger.Warn("Missing key: " + key);
                    }

                    throw ex;
                }

                foreach (var key in getUnusedKeys(properties).Where(key => !configurableKeys.Contains(key)))
                {
                    _logger.Info("Unused key: " + key);
                }

                foreach (var key in getMissingKeys(properties))
                {
                    _logger.Warn("Missing key: " + key);
                }

                foreach (var key in configurableKeys.Where(key => !properties.HasKey(key)))
                {
                    _logger.Warn("Missing key: " + key);
                }

                printUnavailable(CodeGeneratorUtil.GetUnavailable <ICodeGeneratorDataProvider>(types, config.dataProviders));
                printUnavailable(CodeGeneratorUtil.GetUnavailable <ICodeGenerator>(types, config.codeGenerators));
                printUnavailable(CodeGeneratorUtil.GetUnavailable <ICodeGenFilePostProcessor>(types, config.postProcessors));

                printAvailable(CodeGeneratorUtil.GetAvailable <ICodeGeneratorDataProvider>(types, config.dataProviders));
                printAvailable(CodeGeneratorUtil.GetAvailable <ICodeGenerator>(types, config.codeGenerators));
                printAvailable(CodeGeneratorUtil.GetAvailable <ICodeGenFilePostProcessor>(types, config.postProcessors));
            }
            else
            {
                printNoConfig();
            }
        }