diff --git a/src/Maui/Prism.Maui/AppModel/IPageLifecycleAware.cs b/src/Maui/Prism.Maui/AppModel/IPageLifecycleAware.cs index 8885f5909..cbc41127e 100644 --- a/src/Maui/Prism.Maui/AppModel/IPageLifecycleAware.cs +++ b/src/Maui/Prism.Maui/AppModel/IPageLifecycleAware.cs @@ -1,7 +1,17 @@ namespace Prism.AppModel; +/// +/// Interface that defines lifecycle events for pages. +/// public interface IPageLifecycleAware { + /// + /// Called when the page is appearing. + /// void OnAppearing(); + + /// + /// Called when the page is disappearing. + /// void OnDisappearing(); } diff --git a/src/Maui/Prism.Maui/Behaviors/PageLifeCycleAwareBehavior.cs b/src/Maui/Prism.Maui/Behaviors/PageLifeCycleAwareBehavior.cs index 2d6c06e51..a952c0e1f 100644 --- a/src/Maui/Prism.Maui/Behaviors/PageLifeCycleAwareBehavior.cs +++ b/src/Maui/Prism.Maui/Behaviors/PageLifeCycleAwareBehavior.cs @@ -3,8 +3,12 @@ namespace Prism.Behaviors; +/// +/// Provides lifecycle events for and ViewModels. +/// public class PageLifeCycleAwareBehavior : BehaviorBase { + /// protected override void OnAttachedTo(Page bindable) { base.OnAttachedTo(bindable); @@ -12,6 +16,7 @@ protected override void OnAttachedTo(Page bindable) bindable.Disappearing += OnDisappearing; } + /// protected override void OnDetachingFrom(Page bindable) { base.OnDetachingFrom(bindable); diff --git a/src/Maui/Prism.Maui/Behaviors/PageScopeBehavior.cs b/src/Maui/Prism.Maui/Behaviors/PageScopeBehavior.cs index 4fe131302..ce2540ec6 100644 --- a/src/Maui/Prism.Maui/Behaviors/PageScopeBehavior.cs +++ b/src/Maui/Prism.Maui/Behaviors/PageScopeBehavior.cs @@ -7,6 +7,7 @@ namespace Prism.Behaviors; /// public sealed class PageScopeBehavior : BehaviorBase { + /// protected override void OnAttachedTo(Page page) { base.OnAttachedTo(page); @@ -14,6 +15,7 @@ protected override void OnAttachedTo(Page page) Navigation.Xaml.Navigation.GetNavigationService(page); } + /// protected override void OnDetachingFrom(Page page) { base.OnDetachingFrom(page); diff --git a/src/Maui/Prism.Maui/Behaviors/TabbedPageActiveAwareBehavior.cs b/src/Maui/Prism.Maui/Behaviors/TabbedPageActiveAwareBehavior.cs index 8e1775fcc..bee87f2b5 100644 --- a/src/Maui/Prism.Maui/Behaviors/TabbedPageActiveAwareBehavior.cs +++ b/src/Maui/Prism.Maui/Behaviors/TabbedPageActiveAwareBehavior.cs @@ -1,5 +1,8 @@ namespace Prism.Behaviors; +/// +/// Provides support for the children of the +/// public class TabbedPageActiveAwareBehavior : MultiPageActiveAwareBehavior { } diff --git a/src/Maui/Prism.Maui/Dialogs/DialogViewRegistry.cs b/src/Maui/Prism.Maui/Dialogs/DialogViewRegistry.cs index 2df7fc3b9..1edd79622 100644 --- a/src/Maui/Prism.Maui/Dialogs/DialogViewRegistry.cs +++ b/src/Maui/Prism.Maui/Dialogs/DialogViewRegistry.cs @@ -1,15 +1,26 @@ -using Prism.Ioc; -using Prism.Mvvm; +using Prism.Mvvm; namespace Prism.Dialogs; +/// +/// Implementation of a view registry specifically for dialog views. +/// public class DialogViewRegistry : ViewRegistryBase, IDialogViewRegistry { + /// + /// Initializes a new instance of the class with the specified view registrations. + /// + /// The collection of view registrations to manage. public DialogViewRegistry(IEnumerable registrations) : base(ViewType.Dialog, registrations) { } + /// + /// Configures a dialog view with the specified context and container provider. + /// + /// The bindable object representing the dialog view to configure. + /// The container provider to use for resolving dependencies. protected override void ConfigureView(BindableObject bindable, IContainerProvider container) { } diff --git a/src/Maui/Prism.Maui/Dialogs/IDialogViewRegistry.cs b/src/Maui/Prism.Maui/Dialogs/IDialogViewRegistry.cs index af6e6eb7b..fc6f7f0a0 100644 --- a/src/Maui/Prism.Maui/Dialogs/IDialogViewRegistry.cs +++ b/src/Maui/Prism.Maui/Dialogs/IDialogViewRegistry.cs @@ -2,6 +2,9 @@ namespace Prism.Dialogs; +/// +/// Interface that defines a registry for managing views specific to dialogs. +/// public interface IDialogViewRegistry : IViewRegistry { } diff --git a/src/Maui/Prism.Maui/Dialogs/KnownDialogParameters.cs b/src/Maui/Prism.Maui/Dialogs/KnownDialogParameters.cs index fe762355c..7c7f6bde5 100644 --- a/src/Maui/Prism.Maui/Dialogs/KnownDialogParameters.cs +++ b/src/Maui/Prism.Maui/Dialogs/KnownDialogParameters.cs @@ -1,9 +1,18 @@  namespace Prism.Dialogs; +/// +/// Provides well-known parameter names used for configuring dialogs. +/// public static class KnownDialogParameters { + /// + /// Parameter name used to control whether a dialog should close when the background is tapped. + /// public const string CloseOnBackgroundTapped = "closeOnBackgroundTapped"; + /// + /// Parameter name used to pass additional custom parameters to a dialog. + /// public const string XamlParam = "xamlParam"; } diff --git a/src/Maui/Prism.Maui/Dialogs/Xaml/DialogLayout.cs b/src/Maui/Prism.Maui/Dialogs/Xaml/DialogLayout.cs index 4a828e9eb..12526916d 100644 --- a/src/Maui/Prism.Maui/Dialogs/Xaml/DialogLayout.cs +++ b/src/Maui/Prism.Maui/Dialogs/Xaml/DialogLayout.cs @@ -133,11 +133,8 @@ public static void SetMask(BindableObject bindable, View value) => /// True if a mask is used for the dialog, false if not, or null if not explicitly set. public static bool? GetUseMask(BindableObject bindable) { - var value = bindable.GetValue(UseMaskProperty); - if (value is bool boolean) - return boolean; - - return true; // Default to using a mask if not explicitly set + // Default to using a mask if not explicitly set + return bindable.GetValue(UseMaskProperty) is bool boolean ? boolean : true; } /// diff --git a/src/Prism.Core/Common/MulticastExceptionHandler.cs b/src/Prism.Core/Common/MulticastExceptionHandler.cs index 6254f9fc5..8394ed59a 100644 --- a/src/Prism.Core/Common/MulticastExceptionHandler.cs +++ b/src/Prism.Core/Common/MulticastExceptionHandler.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -62,17 +62,15 @@ public async Task HandleAsync(Exception exception, object? parameter = null) return; // Get Invoke() method of the delegate - var invokeMethod = multicastDelegate.GetType().GetMethod("Invoke"); - - if (invokeMethod == null) - throw new InvalidOperationException($"Could not find Invoke() method for delegate of type {multicastDelegate.GetType().Name}"); + var invokeMethod = multicastDelegate.GetType().GetMethod("Invoke") + ?? throw new InvalidOperationException($"Could not find Invoke() method for delegate of type {multicastDelegate.GetType().Name}"); var parameters = invokeMethod.GetParameters(); var arguments = parameters.Length switch { 0 => Array.Empty(), - 1 => typeof(Exception).IsAssignableFrom(parameters[0].ParameterType) ? new object?[] { exception } : new object?[] { parameter }, - 2 => typeof(Exception).IsAssignableFrom(parameters[0].ParameterType) ? new object?[] { exception, parameter } : new object?[] { parameter, exception }, + 1 => typeof(Exception).IsAssignableFrom(parameters[0].ParameterType) ? [exception] : [parameter], + 2 => typeof(Exception).IsAssignableFrom(parameters[0].ParameterType) ? [exception, parameter] : [parameter, exception], _ => throw new InvalidOperationException($"Handler of type {multicastDelegate.GetType().Name} is not supported", exception) }; diff --git a/src/Prism.Core/Mvvm/ViewRegistryBase{TBaseView}.cs b/src/Prism.Core/Mvvm/ViewRegistryBase{TBaseView}.cs index a05711b73..ac0b209e1 100644 --- a/src/Prism.Core/Mvvm/ViewRegistryBase{TBaseView}.cs +++ b/src/Prism.Core/Mvvm/ViewRegistryBase{TBaseView}.cs @@ -99,27 +99,27 @@ private IEnumerable GetCandidates(Type viewModelType) names = names.Where(x => !x.EndsWith("PagePage")).ToList(); - var namespaces = _registryType switch + string[] namespaces = _registryType switch { - ViewType.Page => new[] - { + ViewType.Page => + [ viewModelType.Namespace.Replace("ViewModels", "Views"), viewModelType.Namespace.Replace("ViewModels", "Pages") - }, - ViewType.Region => new[] - { + ], + ViewType.Region => + [ viewModelType.Namespace.Replace("ViewModels", "Views"), viewModelType.Namespace.Replace("ViewModels", "Regions") - }, - ViewType.Dialog => new[] - { + ], + ViewType.Dialog => + [ viewModelType.Namespace.Replace("ViewModels", "Views"), viewModelType.Namespace.Replace("ViewModels", "Dialogs") - }, - _ => new[] - { + ], + _ => + [ viewModelType.Namespace.Replace("ViewModels", "Views"), - } + ] }; var candidates = namespaces.Select(@namespace => names.Select(name => $"{@namespace}.{name}")) @@ -209,15 +209,4 @@ protected ViewRegistration GetRegistration(string name) => /// /// protected abstract void SetContainerProvider(TBaseView view, IContainerProvider container); - - //public static Type GetPageType(string name) - //{ - // var registrations = _registrations.Where(x => x.Name == name); - // if (!registrations.Any()) - // throw new KeyNotFoundException(name); - // if (registrations.Count() > 1) - // throw new InvalidOperationException(string.Format(Resources.MultipleViewsRegisteredForNavigationKey, name, string.Join(", ", registrations.Select(x => x.View.FullName)))); - - // return registrations.First().View; - //} }