Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

View Registry #46

Closed
dansiegel opened this issue May 29, 2022 · 1 comment
Closed

View Registry #46

dansiegel opened this issue May 29, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@dansiegel
Copy link
Member

Description

Prism.Forms has always had a Static NavigationRegistry. This Registry has been there in part to help with mapping Views <---> ViewModels. This also has been a source of pain in Unit Testing as the NavigationRegistry may have the wrong static context if it was not cleared from one test to the next. While Prism.Maui has made a number of improvements around the NavigationRegistry the static nature still remains and is duplicated for Regions. These static APIs should be removed in preference for using the DI Container.

Registration

When Registering a View for Navigation a ViewRegistration instance should be registered along with the View Type & ViewModel Type if specified. The ViewRegistration already exists in Prism.Maui.

Changes

A new ViewType should be added to the ViewRegistration so that we can better filter

public enum ViewType
{
    Page,
    Dialog,
    Region,
}

We can then define a common IViewRegistry & ViewRegistryBase which can be reused for Page Navigation, Regions, & Dialogs.

public interface IViewRegistry
{
    IEnumerable<ViewRegistration> Registrations { get; }

    object CreateView(IContainerProvider container, string name);

    Type GetViewType(string name);

    string GetViewModelNavigationKey(Type viewModelType);

    IEnumerable<ViewRegistration> ViewsOfType(Type baseType);

    bool IsRegistered(string name);
}
@dansiegel dansiegel added the enhancement New feature or request label May 29, 2022
@dansiegel
Copy link
Member Author

closed by #47

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant