示例#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 void Configure(Preferences preferences)
 {
     _codeGeneratorConfig.Configure(preferences);
     _assembliesConfig.Configure(preferences);
     _ignoreNamespacesConfig.Configure(preferences);
     _contextsComponentDataProvider.Configure(preferences);
 }
示例#3
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))
                {
                }
            }
        }
示例#4
0
        public override void Run(string[] args)
        {
            var currentDir = Directory.GetCurrentDirectory();
            var path       = currentDir + Path.DirectorySeparatorChar + Preferences.PATH;

            if (args.isForce() || !File.Exists(path))
            {
                var defaultConfig = new CodeGeneratorConfig();
                var properties    = new Properties(defaultConfig.defaultProperties);
                defaultConfig.Configure(properties);

                var propertiesString = defaultConfig.ToString();
                File.WriteAllText(path, propertiesString);

                fabl.Info("Created " + path);
                fabl.Debug(propertiesString);

                new EditConfig().Run(args);
            }
            else
            {
                fabl.Warn(path + " already exists!");
                fabl.Info("Use entitas new -f to overwrite the exiting file.");
                fabl.Info("Use entitas edit to open the exiting file.");
            }
        }
示例#5
0
        void autoImport()
        {
            var config = new CodeGeneratorConfig();

            config.Configure(_preferences);

            var plugins = config.searchPaths
                          .Concat(new [] { "Assets" })
                          .SelectMany(path => Directory.Exists(path)
                    ? Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories)
                    : new string[0])
                          .Where(path => path.ToLower().EndsWith(".plugins.dll"));

            config.searchPaths = config.searchPaths
                                 .Concat(plugins.Select(path => Path.GetDirectoryName(path)))
                                 .Distinct()
                                 .ToArray();

            config.plugins = plugins
                             .Select(path => Path.GetFileNameWithoutExtension(path))
                             .Distinct()
                             .ToArray();

            _preferences.Save();

            Initialize(_preferences);
            _codeGeneratorConfig.dataProviders  = _availableDataProviderTypes;
            _codeGeneratorConfig.codeGenerators = _availableGeneratorTypes;
            _codeGeneratorConfig.postProcessors = _availablePostProcessorTypes;
        }
示例#6
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);
            }
        }
示例#7
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))
            {
            }
        }
        public static void GenerateWithCLI()
        {
            Debug.Log("Generating...");

            Preferences.sharedInstance.Refresh();
            var config = new CodeGeneratorConfig();

            config.Configure(Preferences.sharedInstance);

            var projectRoot = Application.dataPath.Substring(0, Application.dataPath.Length - "/Assets".Length);
            var cli         = Path.Combine(projectRoot, config.cli);

            if (!File.Exists(cli))
            {
                Debug.Log(cli + " does not exist!");
                return;
            }

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                runCommand(cli, "gen", projectRoot);
            }
            else
            {
                runCommand(config.mono, cli + " gen", projectRoot);
            }

            Debug.Log("Generating done.");

            AssetDatabase.Refresh();
        }
示例#9
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);
        }
示例#10
0
 public void Configure(Preferences preferences)
 {
     _codeGeneratorConfig.Configure(preferences);
     _assembliesConfig.Configure(preferences);
     foreach (var dataProvider in _dataProviders.OfType <IConfigurable>())
     {
         dataProvider.Configure(preferences);
     }
     _contextsComponentDataProvider.Configure(preferences);
 }
示例#11
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);
        }
示例#12
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);
        }
示例#13
0
        void autoImport()
        {
            var config = new CodeGeneratorConfig();

            config.Configure(_preferences);

            var plugins = config.searchPaths
                          .SelectMany(path => Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories))
                          .Where(path => path.ToLower().EndsWith(".plugins.dll"));

            config.searchPaths = config.searchPaths
                                 .Concat(plugins.Select(path => Path.GetDirectoryName(path)))
                                 .Distinct()
                                 .ToArray();

            config.plugins = plugins
                             .Select(path => Path.GetFileNameWithoutExtension(path))
                             .Distinct()
                             .ToArray();

            _preferences.Save();
        }