Created
September 6, 2017 22:53
-
-
Save StefanRiedmann/e4e367dcf27b6ece9a9418c73c73e6b8 to your computer and use it in GitHub Desktop.
PrismApplication with DI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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