├── assets └── gfg.png ├── src ├── DemoProject │ ├── GlobalUsings.cs │ ├── Services │ │ ├── INameService.cs │ │ ├── NameService.cs │ │ ├── IIgnoredService.cs │ │ ├── IPopupDependencyService.cs │ │ ├── IDefaultScopedService.cs │ │ └── ICustomScopedService.cs │ ├── Resources │ │ ├── Images │ │ │ └── dotnet_bot.png │ │ ├── Fonts │ │ │ ├── OpenSans-Regular.ttf │ │ │ └── OpenSans-Semibold.ttf │ │ ├── AppIcon │ │ │ ├── appicon.svg │ │ │ └── appiconfg.svg │ │ ├── Raw │ │ │ └── AboutAssets.txt │ │ ├── Splash │ │ │ └── splash.svg │ │ └── Styles │ │ │ ├── Colors.xaml │ │ │ └── Styles.xaml │ ├── ViewModels │ │ ├── BaseViewModel.cs │ │ ├── PageParamViewModel.cs │ │ ├── VmParamViewModel.cs │ │ ├── AggregateExceptionViewModel.cs │ │ ├── MarkupViewModel.cs │ │ ├── ScopeCheckViewModel.cs │ │ ├── DesktopPageViewModel.cs │ │ └── MainViewModel.cs │ ├── Properties │ │ └── launchSettings.json │ ├── AppShell.xaml.cs │ ├── Pages │ │ ├── MarkupPage.xaml.cs │ │ ├── VmParamPage.xaml.cs │ │ ├── ScopeCheckPage.xaml.cs │ │ ├── DesktopRootPage.xaml.cs │ │ ├── AggregateExceptionPage.xaml.cs │ │ ├── PageParamPage.xaml.cs │ │ ├── AggregateExceptionPage.xaml │ │ ├── BrokenPage.cs │ │ ├── PageParamPage.xaml │ │ ├── VmParamPage.xaml │ │ ├── MarkupPage.xaml │ │ ├── ScopeCheckPage.xaml │ │ └── DesktopRootPage.xaml │ ├── Platforms │ │ ├── Android │ │ │ ├── Resources │ │ │ │ └── values │ │ │ │ │ └── colors.xml │ │ │ ├── MainApplication.cs │ │ │ ├── AndroidManifest.xml │ │ │ └── MainActivity.cs │ │ ├── iOS │ │ │ ├── AppDelegate.cs │ │ │ ├── Program.cs │ │ │ ├── Info.plist │ │ │ └── Resources │ │ │ │ └── PrivacyInfo.xcprivacy │ │ ├── MacCatalyst │ │ │ ├── AppDelegate.cs │ │ │ ├── Program.cs │ │ │ ├── Entitlements.plist │ │ │ └── Info.plist │ │ ├── Windows │ │ │ ├── App.xaml │ │ │ ├── app.manifest │ │ │ ├── App.xaml.cs │ │ │ └── Package.appxmanifest │ │ └── Tizen │ │ │ ├── Main.cs │ │ │ └── tizen-manifest.xml │ ├── MainPage.xaml.cs │ ├── App.xaml.cs │ ├── Popups │ │ ├── ViewModels │ │ │ ├── PopupViewModel.cs │ │ │ └── ParamPopupViewModel.cs │ │ └── Pages │ │ │ ├── EasyPopup.xaml.cs │ │ │ ├── ParamPopup.xaml.cs │ │ │ ├── ParamPopup.xaml │ │ │ └── EasyPopup.xaml │ ├── Conversers │ │ └── NullToVisibleConverter.cs │ ├── App.xaml │ ├── AppShell.xaml │ ├── MauiProgram.cs │ ├── MainPage.xaml │ └── DemoProject.csproj ├── Maui.Plugins.PageResolver.Attributes │ ├── IgnoreAttribute.cs │ ├── SingletonAttribute.cs │ ├── TransientAttribute.cs │ ├── NoAutoDependenciesAttribute.cs │ └── Maui.Plugins.PageResolver.Attributes.csproj ├── Maui.Plugins.PageResolver │ ├── Initializer.cs │ ├── MarkupExtensions.cs │ ├── Maui.Plugins.PageResolver.csproj │ ├── Resolver.cs │ ├── StartupExtensions.cs │ └── NavigationExtensions.cs ├── Maui.Plugins.PageResolver.SourceGenerators │ ├── Log.cs │ ├── Maui.Plugins.PageResolver.SourceGenerators.csproj │ └── AutoDependencies.cs ├── Maui.Plugins.PageResolver.MopupsExtensions │ ├── MopupExtensions.cs │ └── Maui.Plugins.PageResolver.MopupsExtensions.csproj └── Maui.Plugins.PageResolver.sln ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ └── ci.yml ├── README.md ├── LICENSE └── .gitignore /assets/gfg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matt-goldman/Maui.Plugins.PageResolver/HEAD/assets/gfg.png -------------------------------------------------------------------------------- /src/DemoProject/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using DemoProject.Services; 2 | global using DemoProject.ViewModels; 3 | global using Maui.Plugins.PageResolver; -------------------------------------------------------------------------------- /src/DemoProject/Services/INameService.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Services; 2 | 3 | public interface INameService 4 | { 5 | string GetName(); 6 | } 7 | -------------------------------------------------------------------------------- /src/DemoProject/Resources/Images/dotnet_bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matt-goldman/Maui.Plugins.PageResolver/HEAD/src/DemoProject/Resources/Images/dotnet_bot.png -------------------------------------------------------------------------------- /src/DemoProject/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matt-goldman/Maui.Plugins.PageResolver/HEAD/src/DemoProject/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /src/DemoProject/Resources/Fonts/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matt-goldman/Maui.Plugins.PageResolver/HEAD/src/DemoProject/Resources/Fonts/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /src/DemoProject/ViewModels/BaseViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.ViewModels; 2 | 3 | public class BaseViewModel 4 | { 5 | public INavigation? Navigation { get; set; } 6 | } 7 | -------------------------------------------------------------------------------- /src/DemoProject/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "Project", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /src/DemoProject/AppShell.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject; 2 | 3 | public partial class AppShell : Shell 4 | { 5 | public AppShell() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/DemoProject/Pages/MarkupPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Pages; 2 | 3 | public partial class MarkupPage : ContentPage 4 | { 5 | public MarkupPage() 6 | { 7 | InitializeComponent(); 8 | } 9 | } -------------------------------------------------------------------------------- /src/DemoProject/ViewModels/PageParamViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.ViewModels; 2 | 3 | public class PageParamViewModel 4 | { 5 | public string NameParam { get; set; } = string.Empty; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/DemoProject/Services/NameService.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Services; 2 | 3 | public class NameService : INameService 4 | { 5 | public string GetName() 6 | { 7 | return "Maui"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Maui.Plugins.PageResolver.Attributes/IgnoreAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Maui.Plugins.PageResolver.Attributes; 2 | 3 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 4 | public class IgnoreAttribute : Attribute { } 5 | -------------------------------------------------------------------------------- /src/Maui.Plugins.PageResolver.Attributes/SingletonAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Maui.Plugins.PageResolver.Attributes; 2 | 3 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 4 | public class SingletonAttribute : Attribute { } 5 | -------------------------------------------------------------------------------- /src/Maui.Plugins.PageResolver.Attributes/TransientAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Maui.Plugins.PageResolver.Attributes; 2 | 3 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 4 | public class TransientAttribute : Attribute { } 5 | -------------------------------------------------------------------------------- /src/Maui.Plugins.PageResolver.Attributes/NoAutoDependenciesAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Maui.Plugins.PageResolver.Attributes; 2 | 3 | [AttributeUsage(AttributeTargets.Class, Inherited = false)] 4 | public class NoAutoDependenciesAttribute : Attribute { } -------------------------------------------------------------------------------- /src/DemoProject/Pages/VmParamPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Pages; 2 | 3 | public partial class VmParamPage : ContentPage 4 | { 5 | public VmParamPage(VmParamViewModel viewModel) 6 | { 7 | InitializeComponent(); 8 | BindingContext = viewModel; 9 | } 10 | } -------------------------------------------------------------------------------- /src/DemoProject/Pages/ScopeCheckPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Pages; 2 | 3 | public partial class ScopeCheckPage : ContentPage 4 | { 5 | public ScopeCheckPage(ScopeCheckViewModel viewModel) 6 | { 7 | InitializeComponent(); 8 | BindingContext = viewModel; 9 | } 10 | } -------------------------------------------------------------------------------- /src/DemoProject/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | -------------------------------------------------------------------------------- /src/DemoProject/Resources/AppIcon/appicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/DemoProject/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace DemoProject; 4 | 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | -------------------------------------------------------------------------------- /src/DemoProject/Platforms/MacCatalyst/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace DemoProject; 4 | 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | -------------------------------------------------------------------------------- /src/DemoProject/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject; 2 | 3 | public partial class MainPage : ContentPage 4 | { 5 | public MainPage(MainViewModel viewModel) 6 | { 7 | viewModel.Navigation = Navigation; 8 | BindingContext = viewModel; 9 | InitializeComponent(); 10 | } 11 | } -------------------------------------------------------------------------------- /src/DemoProject/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject; 2 | 3 | public partial class App : Application 4 | { 5 | public App() 6 | { 7 | InitializeComponent(); 8 | } 9 | 10 | protected override Window CreateWindow(IActivationState? activationState) 11 | { 12 | return new Window(new AppShell()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Maui.Plugins.PageResolver.Attributes/Maui.Plugins.PageResolver.Attributes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/DemoProject/Popups/ViewModels/PopupViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Popups.ViewModels; 2 | 3 | public class PopupViewModel 4 | { 5 | public string Message { get; set; } 6 | 7 | public PopupViewModel(IPopupDependencyService dependency) 8 | { 9 | Message = dependency.GetMessage(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/DemoProject/Services/IIgnoredService.cs: -------------------------------------------------------------------------------- 1 | using Maui.Plugins.PageResolver.Attributes; 2 | 3 | namespace DemoProject.Services; 4 | 5 | public interface IIgnoredService 6 | { 7 | string GetHello(); 8 | } 9 | 10 | [Ignore] 11 | public class IgnoredService : IIgnoredService 12 | { 13 | public string GetHello() => "Hello"; 14 | } 15 | -------------------------------------------------------------------------------- /src/DemoProject/Pages/DesktopRootPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Pages; 2 | 3 | [XamlCompilation(XamlCompilationOptions.Compile)] 4 | public partial class DesktopRootPage : ContentPage 5 | { 6 | public DesktopRootPage(DesktopPageViewModel viewModel) 7 | { 8 | InitializeComponent(); 9 | BindingContext = viewModel; 10 | } 11 | } -------------------------------------------------------------------------------- /src/DemoProject/Popups/Pages/EasyPopup.xaml.cs: -------------------------------------------------------------------------------- 1 | using DemoProject.Popups.ViewModels; 2 | using Mopups.Pages; 3 | 4 | namespace DemoProject.Popups.Pages; 5 | 6 | public partial class EasyPopup : PopupPage 7 | { 8 | public EasyPopup(PopupViewModel viewModel) 9 | { 10 | InitializeComponent(); 11 | 12 | BindingContext = viewModel; 13 | } 14 | } -------------------------------------------------------------------------------- /src/DemoProject/Pages/AggregateExceptionPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Pages; 2 | 3 | public partial class AggregateExceptionPage : ContentPage 4 | { 5 | public AggregateExceptionPage(AggregateExceptionViewModel vm) 6 | { 7 | InitializeComponent(); 8 | 9 | throw new MissingMemberException("This is a test exception"); 10 | } 11 | } -------------------------------------------------------------------------------- /src/DemoProject/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/DemoProject/Popups/Pages/ParamPopup.xaml.cs: -------------------------------------------------------------------------------- 1 | using DemoProject.Popups.ViewModels; 2 | using Mopups.Pages; 3 | 4 | namespace DemoProject.Popups.Pages; 5 | 6 | public partial class ParamPopup : PopupPage 7 | { 8 | public ParamPopup(ParamPopupViewModel viewModel) 9 | { 10 | InitializeComponent(); 11 | 12 | BindingContext = viewModel; 13 | } 14 | } -------------------------------------------------------------------------------- /src/DemoProject/Popups/ViewModels/ParamPopupViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Popups.ViewModels; 2 | 3 | public class ParamPopupViewModel 4 | { 5 | public string Message { get; set; } 6 | 7 | public ParamPopupViewModel(IPopupDependencyService dependency, string param) 8 | { 9 | Message = dependency.GetParamMessage(param); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/DemoProject/Pages/PageParamPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject; 2 | 3 | [XamlCompilation(XamlCompilationOptions.Compile)] 4 | public partial class PageParamPage : ContentPage 5 | { 6 | public PageParamPage(PageParamViewModel viewModel, string name) 7 | { 8 | InitializeComponent(); 9 | viewModel.NameParam = name; 10 | BindingContext = viewModel; 11 | } 12 | } -------------------------------------------------------------------------------- /src/DemoProject/Platforms/Tizen/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Maui; 3 | using Microsoft.Maui.Hosting; 4 | 5 | namespace DemoProject; 6 | 7 | class Program : MauiApplication 8 | { 9 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 10 | 11 | static void Main(string[] args) 12 | { 13 | var app = new Program(); 14 | app.Run(args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/DemoProject/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Runtime; 3 | 4 | namespace DemoProject; 5 | 6 | [Application] 7 | public class MainApplication : MauiApplication 8 | { 9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership) 10 | : base(handle, ownership) 11 | { 12 | } 13 | 14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 15 | } 16 | -------------------------------------------------------------------------------- /src/DemoProject/ViewModels/VmParamViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.ViewModels; 2 | 3 | public class VmParamViewModel 4 | { 5 | public string NameParam { get; set; } 6 | 7 | public string NameFromServiceParam { get; set; } 8 | 9 | public VmParamViewModel(INameService nameService, string name) 10 | { 11 | NameParam = name; 12 | NameFromServiceParam = nameService.GetName(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/DemoProject/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace DemoProject; 5 | 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/DemoProject/Platforms/MacCatalyst/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace DemoProject; 5 | 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/DemoProject/ViewModels/AggregateExceptionViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.ViewModels; 2 | 3 | public class AggregateExceptionViewModel 4 | { 5 | public string NameParam { get; set; } 6 | 7 | public string NameFromServiceParam { get; set; } 8 | 9 | public AggregateExceptionViewModel(INameService nameService, string name) 10 | { 11 | NameParam = name; 12 | NameFromServiceParam = nameService.GetName(); 13 | } 14 | } -------------------------------------------------------------------------------- /src/DemoProject/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Maui.Plugins.PageResolver/Initializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Maui.Hosting; 3 | 4 | namespace Maui.Plugins.PageResolver 5 | { 6 | internal class Initializer : IMauiInitializeService 7 | { 8 | #region Implementation of IMauiInitializeService 9 | 10 | /// 11 | public void Initialize( IServiceProvider services ) 12 | { 13 | Resolver.RegisterServiceProvider( services ); 14 | } 15 | 16 | #endregion 17 | } 18 | } -------------------------------------------------------------------------------- /src/DemoProject/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | using Android.OS; 4 | 5 | namespace DemoProject; 6 | 7 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] 8 | public class MainActivity : MauiAppCompatActivity 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /src/DemoProject/Conversers/NullToVisibleConverter.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace DemoProject.Conversers; 4 | 5 | internal class NullToVisibleConverter : IValueConverter 6 | { 7 | public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) 8 | { 9 | return value != null; 10 | } 11 | 12 | public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) 13 | { 14 | throw new NotImplementedException(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/DemoProject/Pages/AggregateExceptionPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | -------------------------------------------------------------------------------- /src/DemoProject/Services/IPopupDependencyService.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Services; 2 | 3 | public interface IPopupDependencyService 4 | { 5 | string GetMessage(); 6 | string GetParamMessage(string param); 7 | } 8 | 9 | public class PopupDependencyService : IPopupDependencyService 10 | { 11 | public string GetMessage() 12 | { 13 | return "Hello from PopupDependencyService!"; 14 | } 15 | 16 | public string GetParamMessage(string param) 17 | { 18 | return $"Hello from PopupDependencyService with param: {param}"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/DemoProject/Pages/BrokenPage.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Pages; 2 | 3 | /// 4 | /// This page has a dependency on a service that should not be registered. Runtime exception expected when navigating to this page. 5 | /// 6 | public class BrokenPage : ContentPage 7 | { 8 | public BrokenPage(IIgnoredService ignoredService) 9 | { 10 | Content = new VerticalStackLayout 11 | { 12 | Children = { 13 | new Label { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Text = ignoredService.GetHello() 14 | } 15 | } 16 | }; 17 | } 18 | } -------------------------------------------------------------------------------- /src/DemoProject/Services/IDefaultScopedService.cs: -------------------------------------------------------------------------------- 1 | namespace DemoProject.Services; 2 | 3 | public interface IDefaultScopedService 4 | { 5 | int GetCount(); 6 | void IncreaseCount(int? count = null); 7 | } 8 | 9 | public class DefaultScopedService : IDefaultScopedService 10 | { 11 | private int _count = 0; 12 | 13 | public int GetCount() 14 | { 15 | return _count; 16 | } 17 | 18 | public void IncreaseCount(int? count = null) 19 | { 20 | if (count.HasValue) 21 | { 22 | _count += count.Value; 23 | } 24 | else 25 | { 26 | _count++; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/DemoProject/Services/ICustomScopedService.cs: -------------------------------------------------------------------------------- 1 | using Maui.Plugins.PageResolver.Attributes; 2 | 3 | namespace DemoProject.Services; 4 | 5 | public interface ICustomScopedService : IDefaultScopedService 6 | { 7 | } 8 | 9 | [Transient] 10 | public class CustomScopedService : ICustomScopedService 11 | { 12 | private int _count = 0; 13 | 14 | public int GetCount() 15 | { 16 | return _count; 17 | } 18 | 19 | public void IncreaseCount(int? count = null) 20 | { 21 | if (count.HasValue) 22 | { 23 | _count += count.Value; 24 | } 25 | else 26 | { 27 | _count++; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/DemoProject/ViewModels/MarkupViewModel.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.ComponentModel; 2 | using System.Windows.Input; 3 | 4 | namespace DemoProject.ViewModels; 5 | 6 | [ObservableObject] 7 | public partial class MarkupViewModel : BaseViewModel 8 | { 9 | private readonly INameService _nameService; 10 | 11 | [ObservableProperty] 12 | private string _name = string.Empty; 13 | 14 | public ICommand GetNameCommand => new Command(() => GetName()); 15 | 16 | public MarkupViewModel(INameService nameService) 17 | { 18 | _nameService = nameService; 19 | } 20 | 21 | void GetName() 22 | { 23 | Name = _nameService.GetName(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /src/DemoProject/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/DemoProject/Resources/Raw/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories). Deployment of the asset to your application 3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. 4 | 5 | 6 | 7 | These files will be deployed with your package and will be accessible using Essentials: 8 | 9 | async Task LoadMauiAsset() 10 | { 11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); 12 | using var reader = new StreamReader(stream); 13 | 14 | var contents = reader.ReadToEnd(); 15 | } 16 | -------------------------------------------------------------------------------- /src/DemoProject/Platforms/MacCatalyst/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.apple.security.app-sandbox 8 | 9 | 10 | com.apple.security.network.client 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/DemoProject/AppShell.xaml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 16 | 17 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/DemoProject/Platforms/Windows/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/DemoProject/Platforms/Tizen/tizen-manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | maui-appicon-placeholder 7 | 8 | 9 | 10 | 11 | http://tizen.org/privilege/internet 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/DemoProject/Platforms/Windows/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.UI.Xaml; 2 | 3 | // To learn more about WinUI, the WinUI project structure, 4 | // and more about our project templates, see: http://aka.ms/winui-project-info. 5 | 6 | namespace DemoProject.WinUI; 7 | 8 | /// 9 | /// Provides application-specific behavior to supplement the default Application class. 10 | /// 11 | public partial class App : MauiWinUIApplication 12 | { 13 | /// 14 | /// Initializes the singleton application object. This is the first line of authored code 15 | /// executed, and as such is the logical equivalent of main() or WinMain(). 16 | /// 17 | public App() 18 | { 19 | this.InitializeComponent(); 20 | } 21 | 22 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/Maui.Plugins.PageResolver.SourceGenerators/Log.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace Maui.Plugins.PageResolver.SourceGenerators 5 | { 6 | public static class Log 7 | { 8 | private static StringBuilder _builder; 9 | 10 | public static void Init(StringBuilder builder) 11 | { 12 | _builder = builder; 13 | } 14 | 15 | public static void Write(string entry) 16 | { 17 | _builder.Append($"{DateTime.Now.ToString()} - INFO - {entry}"); 18 | } 19 | 20 | public static void WriteLine(string entry) 21 | { 22 | _builder.AppendLine($"{DateTime.Now.ToString()} - INFO - {entry}"); 23 | } 24 | 25 | public static void FlushLog() 26 | { 27 | System.Diagnostics.Debug.Write(_builder.ToString()); 28 | 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Maui.Plugins.PageResolver.MopupsExtensions/MopupExtensions.cs: -------------------------------------------------------------------------------- 1 | using Mopups.Interfaces; 2 | using Mopups.Pages; 3 | 4 | namespace Maui.Plugins.PageResolver; 5 | 6 | public static class MopupExtensions 7 | { 8 | public static async Task PushAsync(this IPopupNavigation navigation) where T: PopupPage 9 | { 10 | var popup = Resolver.Resolve() as PopupPage 11 | ?? throw new ArgumentException("Could not resolve popup page"); 12 | 13 | await navigation.PushAsync(popup, true); 14 | } 15 | 16 | public static async Task PushAsync(this IPopupNavigation navigation, params object[] parameters) where T : PopupPage 17 | { 18 | var popup = NavigationExtensions.ResolvePage(parameters) as PopupPage 19 | ?? throw new ArgumentException("Could not resolve popup page"); 20 | 21 | await navigation.PushAsync(popup, true); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/DemoProject/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | using DemoProject.Popups.Pages; 2 | using DemoProject.Popups.ViewModels; 3 | using Microsoft.Extensions.Logging; 4 | using Mopups.Hosting; 5 | 6 | namespace DemoProject; 7 | 8 | public static class MauiProgram 9 | { 10 | public static MauiApp CreateMauiApp() 11 | { 12 | var builder = MauiApp.CreateBuilder(); 13 | builder 14 | .UseMauiApp() 15 | .ConfigureFonts(fonts => 16 | { 17 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 18 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); 19 | }) 20 | .ConfigureMopups() 21 | .UseAutodependencies(); 22 | 23 | builder.Services.AddTransient(); 24 | builder.Services.AddTransient(); 25 | 26 | StartupExtensions.UpsertViewModelMapping(); 27 | 28 | #if DEBUG 29 | builder.Logging.AddDebug(); 30 | #endif 31 | 32 | return builder.Build(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/DemoProject/Pages/PageParamPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 11 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PageResolver (Deprecated) 2 | 3 | This repository is no longer maintained. 4 | 5 | The PageResolver library has been renamed, superseded, and fully replaced by: 6 | 7 | ## Plugin.Maui.SmartNavigation 8 | 9 | Migration/upgrade is simple, but there are a couple of breaking changes. 10 | 11 | See the migration guide: [New repository](ttps://github.com/matt-goldman/Plugin.Maui.SmartNavigation) 12 | 13 | New NuGet package: `Plugin.Maui.SmartNavigation` 14 | 15 | SmartNavigation is the direct continuation of this project. 16 | 17 | It includes: 18 | 19 | * A cleaner API surface 20 | * Stronger DI integration 21 | * Type-safe Shell routing 22 | * Improved lifecycle behaviour 23 | * A new source generator 24 | * Updated naming aligned with .NET conventions 25 | * Full support for .NET 10 26 | 27 | This repository is kept as a historical reference only and will not receive updates, fixes, or releases. 28 | 29 | All future development takes place in the SmartNavigation repository. 30 | 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /src/DemoProject/Pages/VmParamPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 24 | -------------------------------------------------------------------------------- /src/Maui.Plugins.PageResolver/MarkupExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Maui.Controls; 3 | using Microsoft.Maui.Controls.Xaml; 4 | using System; 5 | 6 | namespace Maui.Plugins.PageResolver; 7 | 8 | public class ResolveViewModel : IMarkupExtension 9 | { 10 | public T ViewModel { get; set; } 11 | 12 | public T ProvideValue(IServiceProvider serviceProvider) 13 | { 14 | var sp = Resolver.GetServiceProvider(); 15 | var result = sp.GetRequiredService(); 16 | 17 | return result; 18 | } 19 | 20 | object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) 21 | { 22 | return ProvideValue(serviceProvider); 23 | } 24 | } 25 | 26 | [ContentProperty(nameof(ViewModel))] 27 | public class ResolveViewModel : IMarkupExtension 28 | { 29 | public Type ViewModel { get; set; } 30 | 31 | public object ProvideValue(IServiceProvider serviceProvider) 32 | { 33 | var sp = Resolver.GetServiceProvider(); 34 | var result = sp.GetRequiredService(ViewModel); 35 | 36 | return result; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Matt Goldman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/DemoProject/Platforms/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSRequiresIPhoneOS 6 | 7 | UIDeviceFamily 8 | 9 | 1 10 | 2 11 | 12 | UIRequiredDeviceCapabilities 13 | 14 | arm64 15 | 16 | UISupportedInterfaceOrientations 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationLandscapeLeft 20 | UIInterfaceOrientationLandscapeRight 21 | 22 | UISupportedInterfaceOrientations~ipad 23 | 24 | UIInterfaceOrientationPortrait 25 | UIInterfaceOrientationPortraitUpsideDown 26 | UIInterfaceOrientationLandscapeLeft 27 | UIInterfaceOrientationLandscapeRight 28 | 29 | XSAppIconAssets 30 | Assets.xcassets/appicon.appiconset 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/DemoProject/Popups/Pages/ParamPopup.xaml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 20 | 21 | 26 | 27 | -------------------------------------------------------------------------------- /src/DemoProject/Popups/Pages/EasyPopup.xaml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 20 | 21 | 26 | 27 | -------------------------------------------------------------------------------- /src/DemoProject/ViewModels/ScopeCheckViewModel.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Mvvm.ComponentModel; 2 | using System.Windows.Input; 3 | 4 | namespace DemoProject.ViewModels; 5 | 6 | [ObservableObject] 7 | public partial class ScopeCheckViewModel : BaseViewModel 8 | { 9 | private readonly IDefaultScopedService _defaultScopedService; 10 | private readonly ICustomScopedService _customScopedService; 11 | 12 | [ObservableProperty] 13 | private int _defaultCount; 14 | 15 | [ObservableProperty] 16 | private int _customCount; 17 | 18 | public ICommand IncreaseCountCommand => new Command(() => IncreaseCount()); 19 | 20 | public ScopeCheckViewModel(IDefaultScopedService defaultScopedService, ICustomScopedService customScopedService) 21 | { 22 | _defaultScopedService = defaultScopedService; 23 | _customScopedService = customScopedService; 24 | 25 | DefaultCount = _defaultScopedService.GetCount(); 26 | CustomCount = _customScopedService.GetCount(); 27 | } 28 | 29 | public void IncreaseCount() 30 | { 31 | _defaultScopedService.IncreaseCount(); 32 | _customScopedService.IncreaseCount(); 33 | 34 | DefaultCount = _defaultScopedService.GetCount(); 35 | CustomCount = _customScopedService.GetCount(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | version: 7 | description: 'Version to build' 8 | required: true 9 | default: '0.0.0' 10 | 11 | 12 | jobs: 13 | build: 14 | 15 | env: 16 | BUILD_CONFIG: 'Release' 17 | SOLUTION: '.\src\Maui.Plugins.PageResolver.sln' 18 | 19 | runs-on: windows-latest 20 | 21 | steps: 22 | - uses: actions/checkout@v2 23 | 24 | 25 | # - name: Install workloads 26 | # run: dotnet workload install maui maui-windows 27 | 28 | # - name: Restore dependencies 29 | # run: dotnet restore $env:SOLUTION 30 | 31 | - name: Setup .NET 32 | uses: actions/setup-dotnet@v1 33 | with: 34 | dotnet-version: 8.x.x 35 | include-prerelease: false 36 | 37 | - name: Install workloads 38 | run: dotnet workload install maui 39 | 40 | - name: Build 41 | run: dotnet build $env:SOLUTION --configuration $env:BUILD_CONFIG -p:Version=${{ github.event.inputs.version }} 42 | 43 | # - name: Run tests 44 | # run: dotnet test /p:Configuration=$env:BUILD_CONFIG --no-restore --no-build --verbosity normal 45 | 46 | - name: Setup NuGet 47 | uses: NuGet/setup-nuget@v1.0.5 48 | 49 | - name: Publish 50 | run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} -------------------------------------------------------------------------------- /src/Maui.Plugins.PageResolver.MopupsExtensions/Maui.Plugins.PageResolver.MopupsExtensions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8.0 5 | net$(NetCoreVersion) 6 | Enable 7 | true 8 | Matt Goldman 9 | 10 | https://github.com/matt-goldman/Maui.Plugins.PageResolver 11 | Matt Goldman 2024 12 | true 13 | Goldie.MauiPlugins.PageResolver.MopupsExtensions 14 | 15 | Mopups extensions for PageResolver - push popup pages with resolved dependencies 16 | gfg.png 17 | 18 | LICENSE 19 | 2.5.1 20 | 21 | 22 | 23 | 24 | 25 | True 26 | 27 | 28 | 29 | 30 | True 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/DemoProject/Pages/MarkupPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 12 | 13 |