Source/Xamarin/Prism.DryIoc.Forms/DryIocExtensions.cs
/// <summary>
/// Registers a Page for navigation based on the current Device OS using a shared ViewModel
/// </summary>
/// <typeparam name="TView">Default View Type to be shared across multiple Device Operating Systems if they are not specified directly.</typeparam>
/// <typeparam name="TViewModel">Shared ViewModel Type</typeparam>
/// <param name="container"><see cref="IContainer"/> used to register type for Navigation.</param>
/// <param name="name">The unique name to register with the Page. If left empty or null will default to the ViewModel root name. i.e. MyPageViewModel => MyPage</param>
/// <param name="androidView">Android Specific View Type</param>
/// <param name="iOSView">iOS Specific View Type</param>
/// <param name="otherView">Other Platform Specific View Type</param>
/// <param name="windowsView">Windows Specific View Type</param>
/// <param name="winPhoneView">Windows Phone Specific View Type</param>
Registers a Page for navigation based on the current Device OS using a shared ViewModel
Registers a Page for navigation based on the current Device OS using a shared ViewModel
public static void RegisterTypeForNavigationOnPlatform<TView, TViewModel>(this IContainer container, string name = null, Type androidView = null, Type iOSView = null, Type otherView = null, Type windowsView = null, Type winPhoneView = null)
            where TView : Page
            where TViewModel : class
        {
            if (string.IsNullOrWhiteSpace(name))
                name = typeof(TView).Name;
            if (Device.OS == TargetPlatform.Android && androidView != null)
            {
                container.RegisterTypeForNavigationWithViewModel<TViewModel>(androidView, name);
            }
            else if (Device.OS == TargetPlatform.iOS && iOSView != null)
            {
                container.RegisterTypeForNavigationWithViewModel<TViewModel>(iOSView, name);
            }
            else if (Device.OS == TargetPlatform.Other && otherView != null)
            {
                container.RegisterTypeForNavigationWithViewModel<TViewModel>(otherView, name);
            }
            else if (Device.OS == TargetPlatform.Windows && windowsView != null)
            {
                container.RegisterTypeForNavigationWithViewModel<TViewModel>(windowsView, name);
            }
            else if (Device.OS == TargetPlatform.WinPhone && winPhoneView != null)
            {
                container.RegisterTypeForNavigationWithViewModel<TViewModel>(winPhoneView, name);
            }
            else
            {
                container.RegisterTypeForNavigation<TView, TViewModel>(name);
            }
        }
public static void RegisterTypeForNavigationOnPlatform < TView , TViewModel > ( this IContainer container , string name = null , Type androidView = null , Type iOSView = null , Type otherView = null , Type windowsView = null , Type winPhoneView = null ) where TView : Page where TViewModel : class { if ( string . IsNullOrWhiteSpace ( name ) ) name = typeof ( TView ) . Name ; if ( Device . OS == TargetPlatform . Android && androidView != null ) { container . RegisterTypeForNavigationWithViewModel < TViewModel > ( androidView , name ) ; } else if ( Device . OS == TargetPlatform . iOS && iOSView != null ) { container . RegisterTypeForNavigationWithViewModel < TViewModel > ( iOSView , name ) ; } else if ( Device . OS == TargetPlatform . Other && otherView != null ) { container . RegisterTypeForNavigationWithViewModel < TViewModel > ( otherView , name ) ; } else if ( Device . OS == TargetPlatform . Windows && windowsView != null ) { container . RegisterTypeForNavigationWithViewModel < TViewModel > ( windowsView , name ) ; } else if ( Device . OS == TargetPlatform . WinPhone && winPhoneView != null ) { container . RegisterTypeForNavigationWithViewModel < TViewModel > ( winPhoneView , name ) ; } else { container . RegisterTypeForNavigation < TView , TViewModel > ( name ) ; } }
Registers a Page for navigation based on the current Device OS using a shared ViewModel
Registers a Page for navigation based on the current Device OS using a shared ViewModel
IContainer
this
name
string
The unique name to register with the Page. If left empty or null will default to the ViewModel root name. i.e. MyPageViewModel => MyPage
The unique name to register with the Page . If left empty or null will default to the ViewModel root name . i . e . MyPageViewModel = > MyPage
androidView
Type
Android Specific View Type
Android Specific View Type
iOSView
Type
iOS Specific View Type
iOS Specific View Type
otherView
Type
Other Platform Specific View Type
Other Platform Specific View Type
windowsView
Type
Windows Specific View Type
Windows Specific View Type
winPhoneView
Type
Windows Phone Specific View Type
Windows Phone Specific View Type
container
used to register type for Navigation.
used to register type for Navigation .
typeparam
Default View Type to be shared across multiple Device Operating Systems if they are not specified directly.
Default View Type to be shared across multiple Device Operating Systems if they are not specified directly .
typeparam
Shared ViewModel Type
Shared ViewModel Type