Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Add Module list as property of IModuleManager #2179

Closed
dansiegel opened this issue Aug 24, 2020 · 1 comment · Fixed by #2180
Closed

[Enhancement] Add Module list as property of IModuleManager #2179

dansiegel opened this issue Aug 24, 2020 · 1 comment · Fixed by #2180

Comments

@dansiegel
Copy link
Member

Summary

Prism previously introduced a number of great extensions off of the IModuleCatalog to check if a Module exists, or is initialized, however in order to validate the current state of a module you must inject both the IModuleManager and IModuleCatalog, since it is likely that in this scenario you want to load a module if it hasn't been initialized.

API Changes

We would be updating the IModuleManager to include a new property:

public interface IModuleManager
{
    IEnumerable<IModuleInfo> Modules { get; }
}

public class ModuleManager : IModuleManager
{
    // Existing
    protected IModuleCatalog ModuleCatalog { get; }

    // New
    public IEnumerable<IModuleInfo> Modules => ModuleCatalog.Modules;
}

This then allows us to bring some of the extensions we have on the IModuleCatalog over to the IModuleManager to make it easier to work with as we only need to work with a single dependency directly.

Add Extensions for the IModuleManager:

  • bool ModuleExists()
  • bool ModuleExists(string name)
  • ModuleState GetModuleState()
  • ModuleState GetModuleState(string name)
  • bool IsModuleInitialized()
  • bool IsModuleInitialized(string name)
  • void LoadModule()

Add Extensions for IModuleCatalog

  • ModuleState GetModuleState()
  • ModuleState GetModuleState(string name)

Intended Use Case

public void Current()
{
    if(_managerCatalog.Exists<SomeModule>() && !_managerCatalog.IsInitialized<SomeModule>())
    {
        _manager.LoadModule("SomeModule");
    }
}

public void Proposed()
{
    if(_manager.ModuleExists<SomeModule>() && !_manager.IsModuleInitialized<SomeModule>())
    {
        _manager.LoadModule<SomeModule>();
    }
}
@brianlagunas
Copy link
Member

I like it. Ideally, you only care about the IModuleManager and would never need to inject the IModuleCatalog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants