Skip to content

Instantly share code, notes, and snippets.

@StefanRiedmann
Created September 6, 2017 22:53
Show Gist options
  • Save StefanRiedmann/e4e367dcf27b6ece9a9418c73c73e6b8 to your computer and use it in GitHub Desktop.
Save StefanRiedmann/e4e367dcf27b6ece9a9418c73c73e6b8 to your computer and use it in GitHub Desktop.
PrismApplication with DI
public partial class App : PrismApplication
{
private static bool _designContext = true;
public App() : base(null){}
public App(IPlatformInitializer initializer) : base(initializer) { }
protected override void OnInitialized()
{
InitializeComponent();
NavigationService.NavigateAsync("MyMasterDetailPage/MyNavigationPage/MainPage", animated: false);
}
protected override void RegisterTypes()
{
if (_designContext)
{
Container.RegisterType(typeof(ILocationClient), typeof(LocationDummyClient), null,
new ContainerControlledLifetimeManager());
//Register platform specific interface implementations for design time (if you have any)
//types for navigation don't have to be registered for the Previewer
}
else
{
Container.RegisterType(typeof(ILocationClient), typeof(LocationOnlineClient), null,
new ContainerControlledLifetimeManager());
Container.RegisterTypeForNavigation<MyNavigationPage>();
Container.RegisterTypeForNavigation<MainPage>();
Container.RegisterTypeForNavigation<SettingsPage>();
Container.RegisterTypeForNavigation<MyMasterDetailPage>();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment