Example #1
0
 private static void Configure(IEnumerable <ICodeGenerationPlugin> plugins, GenesisSettings settings)
 {
     foreach (var configurable in plugins.OfType <IConfigurable>())
     {
         configurable.Configure(settings);
     }
 }
        protected override void DrawContentBody(GenesisSettings settings)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Auto Import Plugins");
            if (EditorGUILayoutTools.MiniButton("Auto Import"))
            {
                AutoImport(settings);
            }

            EditorGUILayout.EndHorizontal();

            _codeGeneratorConfig.PreProcessors = DrawMaskField(
                "Pre Processors",
                _availablePreProcessorTypes,
                _availablePreProcessorNames,
                _codeGeneratorConfig.PreProcessors);

            _codeGeneratorConfig.DataProviders = DrawMaskField(
                "Data Providers",
                _availableDataProviderTypes,
                _availableDataProviderNames,
                _codeGeneratorConfig.DataProviders);

            _codeGeneratorConfig.CodeGenerators = DrawMaskField(
                "Code Generators",
                _availableGeneratorTypes,
                _availableGeneratorNames,
                _codeGeneratorConfig.CodeGenerators);

            _codeGeneratorConfig.PostProcessors = DrawMaskField(
                "Post Processors",
                _availablePostProcessorTypes,
                _availablePostProcessorNames,
                _codeGeneratorConfig.PostProcessors);
        }
        private void AutoImport(GenesisSettings settings)
        {
            if (!EditorUtility.DisplayDialog(
                    "Genesis - Auto Import",
                    "Auto Import will automatically find and set all plugins for you. It will search in folders and sub folders specified " +
                    "under the key 'Genesis.SearchPaths'.\n\nThis will overwrite your current plugin settings.\n\nDo you want to continue?",
                    "Continue and Overwrite",
                    "Cancel"))
            {
                return;
            }

            var searchPaths = CodeGeneratorTools.BuildSearchPaths(
                _codeGeneratorConfig.SearchPaths,
                new []
            {
                "./Assets",
                "./Library/ScriptAssemblies"
            });

            CodeGeneratorTools.AutoImport(_codeGeneratorConfig, searchPaths);

            EditorUtility.SetDirty(settings);

            Initialize(settings);

            _codeGeneratorConfig.PreProcessors  = _availablePreProcessorTypes;
            _codeGeneratorConfig.DataProviders  = _availableDataProviderTypes;
            _codeGeneratorConfig.CodeGenerators = _availableGeneratorTypes;
            _codeGeneratorConfig.PostProcessors = _availablePostProcessorTypes;
        }
Example #4
0
        protected override void DrawContentBody(GenesisSettings settings)
        {
            // Do Use white-list
            EditorGUILayout.HelpBox(DO_USE_WHITE_LIST_DESCRIPTION, MessageType.Info);
            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField(DO_USE_WHITE_LIST_LABEL);

                using (var scope = new EditorGUI.ChangeCheckScope())
                {
                    var newValue = EditorGUILayout.Toggle(_config.DoUseWhitelistOfAssemblies);

                    if (scope.changed)
                    {
                        _config.DoUseWhitelistOfAssemblies = newValue;

                        EditorUtility.SetDirty(settings);
                    }
                }
            }

            // White-Listed Assemblies
            EditorGUILayout.HelpBox(ASSEMBLY_WHITE_LIST_DESCRIPTION, MessageType.Info);
            using (new EditorGUI.DisabledScope(!_config.DoUseWhitelistOfAssemblies))
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField(ASSEMBLY_WHITE_LIST_LABEL);

                    using (var scope = new EditorGUI.ChangeCheckScope())
                    {
                        var newValue = EditorGUILayout.TextField(_config.RawWhiteListedAssemblies);

                        if (scope.changed)
                        {
                            _config.RawWhiteListedAssemblies = newValue;

                            EditorUtility.SetDirty(settings);
                        }
                    }
                }
            }
        }
Example #5
0
        public static CodeGeneratorRunner CodeGeneratorFromPreferences(GenesisSettings settings)
        {
            var instances           = LoadFromPlugins();
            var andConfigure        = settings.CreateAndConfigure <CodeGeneratorConfig>();
            var enabledInstancesOf1 = GetEnabledInstancesOf <IPreProcessor>(instances, andConfigure.PreProcessors);
            var enabledInstancesOf2 = GetEnabledInstancesOf <IDataProvider>(instances, andConfigure.DataProviders);
            var enabledInstancesOf3 = GetEnabledInstancesOf <ICodeGenerator>(instances, andConfigure.CodeGenerators);
            var enabledInstancesOf4 = GetEnabledInstancesOf <IPostProcessor>(instances, andConfigure.PostProcessors);

            Configure(enabledInstancesOf1, settings);
            Configure(enabledInstancesOf2, settings);
            Configure(enabledInstancesOf3, settings);
            Configure(enabledInstancesOf4, settings);

            return(new CodeGeneratorRunner(
                       enabledInstancesOf1,
                       enabledInstancesOf2,
                       enabledInstancesOf3,
                       enabledInstancesOf4));
        }
Example #6
0
        /// <summary>Initializes any setup for the drawer prior to rendering any GUI.</summary>
        /// <param name="settings"></param>
        public override void Initialize(GenesisSettings settings)
        {
            base.Initialize(settings);

            _config.Configure(settings);
        }
Example #7
0
        /// <summary>
        /// Configures preferences
        /// </summary>
        /// <param name="settings"></param>
        public override void Configure(GenesisSettings settings)
        {
            base.Configure(settings);

            settings.SetIfNotPresent(DEFAULT_VALUES);
        }
 public override void Initialize(GenesisSettings settings)
 {
     // Add default code gen preferences.
     _codeGeneratorConfig.Configure(settings);
 }
Example #9
0
 /// <summary>
 /// Executes a code generation run using the single passed <paramref name="settings"/> asset.
 /// </summary>
 /// <param name="settings"></param>
 public static void GenerateSingle(GenesisSettings settings)
 {
     Generate(new [] { settings });
 }
Example #10
0
        /// <summary>
        /// Executes a code generation run using all <see cref="GenesisSettings"/> assets found in the project.
        /// </summary>
        public static void GenerateAll()
        {
            var allSettings = GenesisSettings.GetAllSettings();

            Generate(allSettings);
        }