Skip to content

Commit

Permalink
Merge pull request #150 from AvaloniaCommunity/feature/Prism9x-v9.0.4…
Browse files Browse the repository at this point in the history
…01-UpgradeGeneric

v9.0.401-pre Upgrade Core Framework
  • Loading branch information
DamianSuess authored Apr 13, 2024
2 parents b263666 + 261e9cd commit 6ea1589
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<!-- Prism -->
<ItemGroup>
<PackageVersion Include="PolySharp" Version="1.14.1" />
<PackageVersion Include="Prism.Core" Version="9.0.271-pre" />
<PackageVersion Include="Prism.Container.Abstractions" Version="9.0.84-pre" />
<PackageVersion Include="Prism.Container.DryIoc" Version="9.0.84-pre" />
Expand Down
8 changes: 4 additions & 4 deletions src/Prism.Avalonia/Common/MvvmHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ view.DataContext is null &&
////#endif

/// <summary>
/// Perform an <see cref="Action{T}"/> on a view and viewmodel.
/// Perform an <see cref="Action{T}"/> on a view and ViewModel.
/// </summary>
/// <remarks>
/// The action will be performed on the view and its viewmodel if they implement <typeparamref name="T"/>.
/// The action will be performed on the view and its ViewModel if they implement <typeparamref name="T"/>.
/// </remarks>
/// <typeparam name="T">The <see cref="Action{T}"/> parameter type.</typeparam>
/// <param name="view">The view to perform the <see cref="Action{T}"/> on.</param>
Expand All @@ -53,15 +53,15 @@ public static void ViewAndViewModelAction<T>(object view, Action<T> action) wher
}

/// <summary>
/// Get an implementer from a view or viewmodel.
/// Get an implementer from a view or ViewModel.
/// </summary>
/// <remarks>
/// If the view implements <typeparamref name="T"/> it will be returned.
/// Otherwise if the view's <see cref="FrameworkElement.DataContext"/> implements <typeparamref name="T"/> it will be returned instead.
/// </remarks>
/// <typeparam name="T">The implementer type to get.</typeparam>
/// <param name="view">The view to get <typeparamref name="T"/> from.</param>
/// <returns>view or viewmodel as <typeparamref name="T"/>.</returns>
/// <returns>view or ViewModel as <typeparamref name="T"/>.</returns>
public static T GetImplementerFromViewOrViewModel<T>(object view) where T : class
{
if (view is T viewAsT)
Expand Down
15 changes: 8 additions & 7 deletions src/Prism.Avalonia/Ioc/IContainerRegistryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Prism.Mvvm;

namespace Prism.Ioc
Expand All @@ -14,7 +15,7 @@ public static class IContainerRegistryExtensions
/// <typeparam name="TView">The Type of object to register as the dialog</typeparam>
/// <param name="containerRegistry"></param>
/// <param name="name">The unique name to register with the dialog.</param>
public static void RegisterDialog<TView>(this IContainerRegistry containerRegistry, string name = null)
public static void RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView>(this IContainerRegistry containerRegistry, string name = null)
{
containerRegistry.RegisterForNavigation<TView>(name);
}
Expand All @@ -26,7 +27,7 @@ public static void RegisterDialog<TView>(this IContainerRegistry containerRegist
/// <typeparam name="TViewModel">The ViewModel to use as the DataContext for the dialog</typeparam>
/// <param name="containerRegistry"></param>
/// <param name="name">The unique name to register with the dialog.</param>
public static void RegisterDialog<TView, TViewModel>(this IContainerRegistry containerRegistry, string name = null) where TViewModel : Dialogs.IDialogAware
public static void RegisterDialog<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null) where TViewModel : Dialogs.IDialogAware
{
containerRegistry.RegisterForNavigation<TView, TViewModel>(name);
}
Expand All @@ -36,7 +37,7 @@ public static void RegisterDialog<TView, TViewModel>(this IContainerRegistry con
/// </summary>
/// <typeparam name="TWindow">The Type of the Window class that will be used to host dialogs in the IDialogService</typeparam>
/// <param name="containerRegistry"></param>
public static void RegisterDialogWindow<TWindow>(this IContainerRegistry containerRegistry) where TWindow : Dialogs.IDialogWindow
public static void RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry) where TWindow : Dialogs.IDialogWindow
{
containerRegistry.Register(typeof(Dialogs.IDialogWindow), typeof(TWindow));
}
Expand All @@ -47,7 +48,7 @@ public static void RegisterDialogWindow<TWindow>(this IContainerRegistry contain
/// <typeparam name="TWindow">The Type of the Window class that will be used to host dialogs in the IDialogService</typeparam>
/// <param name="containerRegistry"></param>
/// <param name="name">The name of the dialog window</param>
public static void RegisterDialogWindow<TWindow>(this IContainerRegistry containerRegistry, string name) where TWindow : Dialogs.IDialogWindow
public static void RegisterDialogWindow<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TWindow>(this IContainerRegistry containerRegistry, string name) where TWindow : Dialogs.IDialogWindow
{
containerRegistry.Register(typeof(Dialogs.IDialogWindow), typeof(TWindow), name);
}
Expand All @@ -69,7 +70,7 @@ public static void RegisterForNavigation(this IContainerRegistry containerRegist
/// <typeparam name="T">The Type of the object to register as the view</typeparam>
/// <param name="containerRegistry"></param>
/// <param name="name">The unique name to register with the object.</param>
public static void RegisterForNavigation<T>(this IContainerRegistry containerRegistry, string name = null)
public static void RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(this IContainerRegistry containerRegistry, string name = null)
{
Type type = typeof(T);
string viewName = string.IsNullOrWhiteSpace(name) ? type.Name : name;
Expand All @@ -83,12 +84,12 @@ public static void RegisterForNavigation<T>(this IContainerRegistry containerReg
/// <typeparam name="TViewModel">The ViewModel to use as the DataContext for the view</typeparam>
/// <param name="containerRegistry"></param>
/// <param name="name">The unique name to register with the view</param>
public static void RegisterForNavigation<TView, TViewModel>(this IContainerRegistry containerRegistry, string name = null)
public static void RegisterForNavigation<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TView, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, string name = null)
{
containerRegistry.RegisterForNavigationWithViewModel<TViewModel>(typeof(TView), name);
}

private static void RegisterForNavigationWithViewModel<TViewModel>(this IContainerRegistry containerRegistry, Type viewType, string name)
private static void RegisterForNavigationWithViewModel<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TViewModel>(this IContainerRegistry containerRegistry, Type viewType, string name)
{
if (string.IsNullOrWhiteSpace(name))
name = viewType.Name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Prism.Ioc;
using Prism.Properties;
Expand Down Expand Up @@ -49,7 +50,7 @@ public void RegisterMapping<TControl>(IRegionAdapter adapter)
/// </summary>
/// <typeparam name="TControl">The type of the control</typeparam>
/// <typeparam name="TAdapter">The type of the IRegionAdapter to use with the TControl</typeparam>
public void RegisterMapping<TControl, TAdapter>() where TAdapter : IRegionAdapter
public void RegisterMapping<TControl, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] TAdapter>() where TAdapter : IRegionAdapter
{
RegisterMapping(typeof(TControl), ContainerLocator.Container.Resolve<TAdapter>());
}
Expand Down
3 changes: 0 additions & 3 deletions src/Prism.Avalonia/Prism.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ Prism.Avalonia helps you more easily design and build rich, flexible, and easy t

<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" />
<!--<PackageReference Include="Avalonia" />
<PackageReference Include="Avalonia.Markup.Xaml.Loader" />
<PackageReference Include="Avalonia.ReactiveUI" />-->
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 6ea1589

Please sign in to comment.