Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Created December 7, 2016 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuka1984/851a7636c884ae6d01bfcb131f5e2f06 to your computer and use it in GitHub Desktop.
Save yuka1984/851a7636c884ae6d01bfcb131f5e2f06 to your computer and use it in GitHub Desktop.
public class App : PrismApplication
{
private const string _navigationServiceName = "UnityPageNavigationService";
public App(IPlatformInitializer initializer = null) : base(initializer)
{
}
protected override void ConfigureContainer()
{
Container.AddNewExtension<DependencyServiceExtension>();
Container.RegisterInstance(Logger);
Container.RegisterInstance(ModuleCatalog);
Container.RegisterType<IApplicationProvider, ApplicationProvider>(new ContainerControlledLifetimeManager());
Container.RegisterType<INavigationService, UnityCustomPageNavigationService>(_navigationServiceName);
Container.RegisterType<IModuleManager, ModuleManager>(new ContainerControlledLifetimeManager());
Container.RegisterType<IModuleInitializer, UnityModuleInitializer>(new ContainerControlledLifetimeManager());
Container.RegisterType<IEventAggregator, EventAggregator>(new ContainerControlledLifetimeManager());
Container.RegisterType<IDependencyService, Prism.Services.DependencyService>(new ContainerControlledLifetimeManager());
Container.RegisterType<IPageDialogService, PageDialogService>(new ContainerControlledLifetimeManager());
}
protected async override void OnInitialized()
{
await NavigationService.NavigateAsync("RootPage/Content2");
}
protected override void RegisterTypes()
{
Container.RegisterTypeForNavigation<Content1>();
Container.RegisterTypeForNavigation<Content2>();
Container.RegisterTypeForNavigation<Content3>();
Container.RegisterTypeForNavigation<SubContent1>();
switch (new Random().Next() % 3)
{
case 0:
Container.RegisterTypeForNavigation<MyTabbedMasterDetailPage>("RootPage");
break;
case 1:
Container.RegisterTypeForNavigation<MyTabbedPage>("RootPage");
break;
default:
Container.RegisterTypeForNavigation<MyCarouselPage>("RootPage");
break;
}
}
public class MyTabbedMasterDetailPage : TabbedMasterDetailPage
{
public MyTabbedMasterDetailPage() : base()
{
this.Children.Add(new Content1());
this.Children.Add(new Content2());
this.Children.Add(new Content3());
}
}
public class MyTabbedPage : TabbedPage
{
public MyTabbedPage() : base()
{
this.Children.Add(new Content1());
this.Children.Add(new Content2());
this.Children.Add(new Content3());
}
}
public class MyCarouselPage : CarouselPage
{
public MyCarouselPage() : base()
{
this.Children.Add(new Content1());
this.Children.Add(new Content2());
this.Children.Add(new Content3());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment