Skip to content

Commit

Permalink
fixing issue with DryIoc injecting a Page to IPageAware
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed May 5, 2020
1 parent 165e697 commit 6544370
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 35 deletions.
32 changes: 1 addition & 31 deletions src/Forms/Prism.DryIoc.Forms/PrismApplication.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using System;
using System.Linq;
using System.Reflection;
using DryIoc;
using Prism.Common;
using DryIoc;
using Prism.Ioc;
using Prism.Logging;
using Prism.Navigation;
using Xamarin.Forms;
using Xamarin.Forms.Internals;

[assembly: Xamarin.Forms.XmlnsDefinition("http://prismlibrary.com", "Prism.DryIoc")]
Expand Down Expand Up @@ -55,28 +48,5 @@ protected override IContainerExtension CreateContainerExtension()
/// </summary>
/// <returns>An instance of <see cref="Rules" /></returns>
protected virtual Rules CreateContainerRules() => DryIocContainerExtension.DefaultRules;

/// <summary>
/// Configures the Container.
/// </summary>
/// <param name="containerRegistry"></param>
protected override void RegisterRequiredTypes(IContainerRegistry containerRegistry)
{
base.RegisterRequiredTypes(containerRegistry);
containerRegistry.GetContainer().Register<INavigationService, PageNavigationService>();
containerRegistry.GetContainer().Register<INavigationService>(
made: Made.Of(() => SetPage(Arg.Of<INavigationService>(), Arg.Of<Page>())),
setup: Setup.Decorator);
}

internal static INavigationService SetPage(INavigationService navigationService, Page page)
{
if (navigationService is IPageAware pageAware)
{
pageAware.Page = page;
}

return navigationService;
}
}
}
4 changes: 0 additions & 4 deletions src/Forms/Prism.Forms/PrismApplicationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ protected virtual void Initialize()
_containerExtension.CreateScope();
NavigationService = _containerExtension.Resolve<INavigationService>();

// Ensure the Container doesn't inflate a Xamarin.Forms.Page here...
if (NavigationService is IPageAware pageAware)
pageAware.Page = null;

InitializeModules();
}

Expand Down

0 comments on commit 6544370

Please sign in to comment.