예제 #1
0
        static void printPluginStatus(Type[] types, CodeGeneratorConfig config)
        {
            var unavailableDataProviders  = CodeGeneratorUtil.GetUnavailableNamesOf <ICodeGeneratorDataProvider>(types, config.dataProviders);
            var unavailableCodeGenerators = CodeGeneratorUtil.GetUnavailableNamesOf <ICodeGenerator>(types, config.codeGenerators);
            var unavailablePostProcessors = CodeGeneratorUtil.GetUnavailableNamesOf <ICodeGenFilePostProcessor>(types, config.postProcessors);

            var availableDataProviders  = CodeGeneratorUtil.GetAvailableNamesOf <ICodeGeneratorDataProvider>(types, config.dataProviders);
            var availableCodeGenerators = CodeGeneratorUtil.GetAvailableNamesOf <ICodeGenerator>(types, config.codeGenerators);
            var availablePostProcessors = CodeGeneratorUtil.GetAvailableNamesOf <ICodeGenFilePostProcessor>(types, config.postProcessors);

            printUnavailable(unavailableDataProviders);
            printUnavailable(unavailableCodeGenerators);
            printUnavailable(unavailablePostProcessors);

            printAvailable(availableDataProviders);
            printAvailable(availableCodeGenerators);
            printAvailable(availablePostProcessors);
        }
예제 #2
0
        static bool fixPlugins(HashSet <string> askedRemoveKeys, HashSet <string> askedAddKeys, Type[] types, CodeGeneratorConfig config, Preferences preferences)
        {
            var changed = false;

            var unavailableDataProviders  = CodeGeneratorUtil.GetUnavailableNamesOf <ICodeGeneratorDataProvider>(types, config.dataProviders);
            var unavailableCodeGenerators = CodeGeneratorUtil.GetUnavailableNamesOf <ICodeGenerator>(types, config.codeGenerators);
            var unavailablePostProcessors = CodeGeneratorUtil.GetUnavailableNamesOf <ICodeGenFilePostProcessor>(types, config.postProcessors);

            var availableDataProviders  = CodeGeneratorUtil.GetAvailableNamesOf <ICodeGeneratorDataProvider>(types, config.dataProviders);
            var availableCodeGenerators = CodeGeneratorUtil.GetAvailableNamesOf <ICodeGenerator>(types, config.codeGenerators);
            var availablePostProcessors = CodeGeneratorUtil.GetAvailableNamesOf <ICodeGenFilePostProcessor>(types, config.postProcessors);

            foreach (var key in unavailableDataProviders)
            {
                if (!askedRemoveKeys.Contains(key))
                {
                    Helper.RemoveValue("Remove unavailable data provider", key, config.dataProviders,
                                       values => config.dataProviders = values, preferences);
                    askedRemoveKeys.Add(key);
                    changed = true;
                }
            }

            foreach (var key in unavailableCodeGenerators)
            {
                if (!askedRemoveKeys.Contains(key))
                {
                    Helper.RemoveValue("Remove unavailable code generator", key, config.codeGenerators,
                                       values => config.codeGenerators = values, preferences);
                    askedRemoveKeys.Add(key);
                    changed = true;
                }
            }

            foreach (var key in unavailablePostProcessors)
            {
                if (!askedRemoveKeys.Contains(key))
                {
                    Helper.RemoveValue("Remove unavailable post processor", key, config.postProcessors,
                                       values => config.postProcessors = values, preferences);
                    askedRemoveKeys.Add(key);
                    changed = true;
                }
            }

            foreach (var key in availableDataProviders)
            {
                if (!askedAddKeys.Contains(key))
                {
                    Helper.AddValue("Add available data provider", key, config.dataProviders,
                                    values => config.dataProviders = values, preferences);
                    askedAddKeys.Add(key);
                    changed = true;
                }
            }

            foreach (var key in availableCodeGenerators)
            {
                if (!askedAddKeys.Contains(key))
                {
                    Helper.AddValue("Add available code generator", key, config.codeGenerators,
                                    values => config.codeGenerators = values, preferences);
                    askedAddKeys.Add(key);
                    changed = true;
                }
            }

            foreach (var key in availablePostProcessors)
            {
                if (!askedAddKeys.Contains(key))
                {
                    Helper.AddValue("Add available post processor", key, config.postProcessors,
                                    values => config.postProcessors = values, preferences);
                    askedAddKeys.Add(key);
                    changed = true;
                }
            }

            return(changed);
        }