Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matt-goldman/Maui.Plugins.PageResolver
A simple and lightweight page resolver for use in .NET MAUI projects
https://github.com/matt-goldman/Maui.Plugins.PageResolver
dependency-injection dotnet dotnetmaui source-generator
Last synced: 3 months ago
JSON representation
A simple and lightweight page resolver for use in .NET MAUI projects
- Host: GitHub
- URL: https://github.com/matt-goldman/Maui.Plugins.PageResolver
- Owner: matt-goldman
- License: mit
- Created: 2021-06-16T22:51:25.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-29T22:54:46.000Z (3 months ago)
- Last Synced: 2024-07-30T04:17:21.394Z (3 months ago)
- Topics: dependency-injection, dotnet, dotnetmaui, source-generator
- Language: C#
- Homepage:
- Size: 250 KB
- Stars: 127
- Watchers: 7
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-dotnet-maui - Maui.Plugins.PageResolver - goldman/Maui.Plugins.PageResolver?style=flat-square)](https://github.com/matt-goldman/Maui.Plugins.PageResolver/stargazers)|[![GitHub last-commit](https://img.shields.io/github/last-commit/matt-goldman/Maui.Plugins.PageResolver?style=flat-square)](https://github.com/matt-goldman/Maui.Plugins.PageResolver/commits) (Plugins)
- awesome-maui - Maui.Plugins.PageResolver - goldman/Maui.Plugins.PageResolver?style=flat-square)](https://github.com/matt-goldman/Maui.Plugins.PageResolver/issues) [![GitHub stars](https://img.shields.io/github/stars/matt-goldman/Maui.Plugins.PageResolver?style=flat-square)](https://github.com/matt-goldman/Maui.Plugins.PageResolver/stargazers) ![last commit](https://img.shields.io/github/last-commit/matt-goldman/Maui.Plugins.PageResolver?style=flat-square) - A simple and lightweight page resolver for use in .NET MAUI projects. (Plugins / Get Started)
README
[![NuGet Status](https://img.shields.io/nuget/v/Goldie.MauiPlugins.PageResolver.svg?style=flat)](https://www.nuget.org/packages/Goldie.MauiPlugins.PageResolver/) [![Nuget](https://img.shields.io/nuget/dt/Goldie.MauiPlugins.PageResolver)](https://www.nuget.org/packages/Goldie.MauiPlugins.PageResolver)
## Watch the video:
# MAUI PageResolver
A simple and lightweight page resolver for use in .NET MAUI projects.If you want a simple page resolver with DI without using a full MVVM framework (or if you want to use MVU), this package will let you navigate to fully resolved pages, with view models and dependencies, by calling:
```cs
await Navigation.PushAsync();
```# Advanced features
Additional features supported by PageReolver:
* Paramaterised navigation - pass page parameters```csharp
await Navigation.PushAsync(myPageParam1, "bob", 4);
```* Paramaterised navigation - pass ViewModel parameters (.NET 8 version only)
```csharp
await Navigation.PushAsync(myViewModelParam1, "bob", 4);
```* Source generator - automatically register dependencies in `IServiceCollection` with generated code (.NET 8 version only)
```csharp
using Maui.Plugins.PageResolver;
using DemoProject;
using DemoProject.Pages;
using DemoProject.ViewModels;
using DemoProject.Services;
// ---------------
//
// Generated by the MauiPageResolver Auto-registration module.
// https://github.com/matt-goldman/Maui.Plugins.PageResolver
//
// ---------------namespace DemoProject;
public static class PageResolverExtensions
{public static MauiAppBuilder UseAutodependencies(this MauiAppBuilder builder)
{
var ViewModelMappings = new Dictionary();// pages
builder.Services.AddTransient();// ViewModels
builder.Services.AddTransient();// Services
builder.Services.AddSingleton();
builder.Services.AddTransient();// ViewModel to Page mappings
ViewModelMappings.Add(typeof(MainPage), typeof(MainViewModel));// Initialisation
builder.Services.UsePageResolver(ViewModelMappings);
return builder;
}
}
```* Lifetime attributes - override convention-based service lifetimes (singleton for services, transient for pages and ViewModels) in the source generator (.NET 8 version only)
```csharp
[Transient]
public class CustomScopedService : ICustomScopedService
{
[...]
```# Getting Started
Check out the full instructions in the wiki on [using PageResolver](https://github.com/matt-goldman/Maui.Plugins.PageResolver/wiki/1-Using-the-PageResolver)