public ModulesMenu()
        {
            SetMenuName();
            SetMenuStyle();

            List <Type> types = AppDomain.CurrentDomain.GetAssemblies()
                                .SelectMany(x => x.GetTypes())
                                .Where(x => !x.IsAbstract && Utilities.ImplementsOrInherits(x, typeof(IPackageManagerModule)))
                                .ToList();

            if (types.Count == 0)
            {
                menu.AppendAction("No modules available", null);
                return;
            }

            foreach (Type type in types)
            {
                IPackageManagerModule module = (IPackageManagerModule)Activator.CreateInstance(type);
                modules.Add(module.Identifier, module);

                menu.AppendAction(module.DisplayName, ToggleModule, GetModuleStatus, module.Identifier);

                module.Initialize();
                if (WasEnabled(module))
                {
                    module.Enable();
                }
            }

            RegisterCallback <AttachToPanelEvent>(OnAttachToPanel, TrickleDown.TrickleDown);
            RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel, TrickleDown.TrickleDown);
            CompilationPipeline.compilationStarted += OnStartCompiling;
        }
        private void OnAttachToPanelDelayed()
        {
            foreach (KeyValuePair <string, IPackageManagerModule> kvp in modules)
            {
                IPackageManagerModule module = kvp.Value;
                module.Initialize();

                if (WasEnabled(module))
                {
                    module.Enable();
                }
            }
        }
        private void ToggleModule(DropdownMenuAction dropdownMenuAction)
        {
            IPackageManagerModule module = modules[(string)dropdownMenuAction.userData];

            if (module.IsEnabled)
            {
                module.Disable();
            }
            else
            {
                module.Enable();
            }

            EditorPrefs.SetBool(GetKey(module, KEY_ENABLED), module.IsEnabled);
        }