Beispiel #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);
            }
        }
Beispiel #2
0
 public override void Run(string[] args)
 {
     if (assertPreferences(args))
     {
         printTypes(CodeGeneratorUtil.LoadTypesFromPlugins(loadPreferences(args)));
     }
 }
Beispiel #3
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);
            }
        }
Beispiel #4
0
        public override void Run(string[] args)
        {
            if (assertPreferences(args))
            {
                var preferences = loadPreferences(args);
                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);
                    getConfigurables(types, config);
                } catch (Exception ex) {
                    throw ex;
                }

                var askedRemoveKeys = new HashSet <string>();
                var askedAddKeys    = new HashSet <string>();
                while (fix(askedRemoveKeys, askedAddKeys, types, config, cliConfig, preferences))
                {
                }
            }
        }
Beispiel #5
0
        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))
            {
            }
        }
Beispiel #6
0
        protected override void run()
        {
            var config = new CodeGeneratorConfig();

            config.Configure(_preferences);

            var cliConfig = new CLIConfig();

            cliConfig.Configure(_preferences);

            fabl.Debug(_preferences.ToString());

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

            try {
                types             = CodeGeneratorUtil.LoadTypesFromPlugins(_preferences);
                defaultProperties = CodeGeneratorUtil.GetDefaultProperties(types, config);
            } catch (Exception ex) {
                printKeyStatus(config.defaultProperties.Keys.ToArray(), cliConfig, _preferences);
                throw ex;
            }

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

            printKeyStatus(requiredKeys, cliConfig, _preferences);
            printPluginStatus(types, config);
            printCollisions(config);
        }
Beispiel #7
0
        protected override void run()
        {
            var types        = CodeGeneratorUtil.LoadTypesFromPlugins(_preferences);
            var orderedTypes = types
                               .OrderBy(type => type.Assembly.GetName().Name)
                               .ThenBy(type => type.FullName);

            foreach (var type in orderedTypes)
            {
                fabl.Info(type.Assembly.GetName().Name + ": " + type);
            }
        }
Beispiel #8
0
        public override void Initialize(Preferences preferences)
        {
            _preferences         = preferences;
            _codeGeneratorConfig = new CodeGeneratorConfig();
            preferences.AddProperties(_codeGeneratorConfig.defaultProperties, false);
            _codeGeneratorConfig.Configure(preferences);

            _types = CodeGeneratorUtil.LoadTypesFromPlugins(preferences);

            initPhase <ICodeGeneratorDataProvider>(_types, out _availableDataProviderTypes, out _availableDataProviderNames);
            initPhase <ICodeGenerator>(_types, out _availableGeneratorTypes, out _availableGeneratorNames);
            initPhase <ICodeGenFilePostProcessor>(_types, out _availablePostProcessorTypes, out _availablePostProcessorNames);

            _preferences.AddProperties(getConfigurables(), false);
        }
Beispiel #9
0
        public override void Initialize(Properties properties)
        {
            mProperties          = properties;
            mCodeGeneratorConfig = new CodeGeneratorConfig();
            properties.AddProperties(mCodeGeneratorConfig.DefaultProperties, false);
            mCodeGeneratorConfig.Configure(properties);

            mTypes = CodeGeneratorUtil.LoadTypesFromPlugins(properties);

            InitPhase <ICodeGeneratorDataProvider>(mTypes, out mAvailableDataProviderTypes,
                                                   out mAvailableDataProviderNames);
            InitPhase <ICodeGenerator>(mTypes, out mAvailableGeneratorTypes, out mAvailableGeneratorNames);
            InitPhase <ICodeGenFilePostProcessor>(mTypes, out mAvailablePostProcessorTypes,
                                                  out mAvailablePostProcessorNames);

            mProperties.AddProperties(GetConfigurables(), false);
        }