protected override void RegisterTypes(ICodeBrixContainer container)
        {
            container.RegisterForNavigation <MainPage>();
            container.RegisterForNavigation <RecipePage>();

            container.RegisterLazySingleton(() => new RecipeService(), typeof(IRecipeService));
        }
        protected override void RegisterTypes(ICodeBrixContainer container)
        {
            container.RegisterForNavigation <MainPage>();
            container.RegisterForNavigation <TabA, TabViewModel>();
            container.RegisterForNavigation <TabB, TabViewModel>();
            container.RegisterForNavigation <TabC, TabViewModel>();

            container.RegisterSingleton(new ApplicationCommands(), typeof(IApplicationCommands));
        }
Exemple #3
0
        protected override void RegisterTypes(ICodeBrixContainer container)
        {
            container.RegisterForNavigation <MainPage>();
            container.RegisterForNavigation <LoginPage>();
            container.RegisterForNavigation <ViewA>();
            container.RegisterForNavigation <ViewB>();
            container.RegisterForNavigation <ViewC>();

            container.RegisterLazySingleton(typeof(IAuthenticationService), typeof(AuthenticationService));
        }
        //public App ()
        //{
        //	InitializeComponent();
        //
        //    MainPage = new MainPage();
        //}

        //CODEBRIX-CONVERSION-NOTE: The main App class (inherited from CodeBrixApplication) also needs
        // to override the RegisterTypes() method - this is where our pages are registered for navigation
        // and our shared platform specific services are registered (platform-specific services have to be
        // registered in the platform projects: in AppDelegate (for iOS), MainActivity (for Android), etc.)
        protected override void RegisterTypes(ICodeBrixContainer container)
        {
            container.RegisterForNavigation <MainPage>();
            container.RegisterForNavigation <AboutPage, AboutViewModel>();
            container.RegisterForNavigation <ItemDetailPage, ItemDetailViewModel>();
            container.RegisterForNavigation <ItemsPage, ItemsViewModel>();
            container.RegisterForNavigation <NewItemPage, NewItemViewModel>();

            //We might choose to register the MockDataStore with the container here - as our implementation
            // of IDataStore<Item> - using a line of code like the commented-out one below.
            // However, in this sample app - as generated by Visual Studio - the MockDataStore is already
            // registered with the Xamarin.Forms.DependencyService, so our CodeBrixContainer will already be
            // able to resolve it.
            //container.Register(() => new MockDataStore(), typeof(IDataStore<Models.Item>));
        }
Exemple #5
0
        /// <summary>
        /// Registers a Page for navigation based on the Device Idiom using a shared ViewModel
        /// </summary>
        /// <typeparam name="TView">Default View Type to be used across multiple Idioms if they are not specified directly.</typeparam>
        /// <typeparam name="TViewModel">The shared ViewModel</typeparam>
        /// <param name="container"><see cref="ICodeBrixContainer"/> used to register type for Navigation.</param>
        /// <param name="name">The common name used for Navigation. If left empty or null will default to the ViewModel root name. i.e. MyPageViewModel => MyPage</param>
        /// <param name="desktopView">Desktop Specific View Type</param>
        /// <param name="tabletView">Tablet Specific View Type</param>
        /// <param name="phoneView">Phone Specific View Type</param>
        public static void RegisterForNavigationOnIdiom <TView, TViewModel>(this ICodeBrixContainer container, string name = null, Type desktopView = null, Type tabletView = null, Type phoneView = null)
            where TView : Page
            where TViewModel : class
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = typeof(TView).Name;
            }

            if (Device.Idiom == TargetIdiom.Desktop && desktopView != null)
            {
                container.RegisterForNavigationWithViewModel <TViewModel>(desktopView, name);
            }
            else if (Device.Idiom == TargetIdiom.Phone && phoneView != null)
            {
                container.RegisterForNavigationWithViewModel <TViewModel>(phoneView, name);
            }
            else if (Device.Idiom == TargetIdiom.Tablet && tabletView != null)
            {
                container.RegisterForNavigationWithViewModel <TViewModel>(tabletView, name);
            }
            else
            {
                container.RegisterForNavigation <TView, TViewModel>(name);
            }
        }
Exemple #6
0
        // ReSharper disable InconsistentNaming

        /// <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="ICodeBrixContainer"/> 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="UWPView">Windows Universal (UWP) Specific View Type</param>
        /// <param name="macOSView">macOS Specific View Type</param>
        /// <param name="otherView">Other Platform Specific View Type</param>
        public static void RegisterForNavigationOnPlatform <TView, TViewModel>(this ICodeBrixContainer container, string name = null, Type androidView = null, Type iOSView = null, Type UWPView = null, Type macOSView = null, Type otherView = null)
            where TView : Page
            where TViewModel : class
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = typeof(TView).Name;
            }

            if (Device.RuntimePlatform == Device.Android && androidView != null)
            {
                container.RegisterForNavigationWithViewModel <TViewModel>(androidView, name);
            }
            else if (Device.RuntimePlatform == Device.iOS && iOSView != null)
            {
                container.RegisterForNavigationWithViewModel <TViewModel>(iOSView, name);
            }
            else if (Device.RuntimePlatform == Device.UWP && UWPView != null)
            {
                container.RegisterForNavigationWithViewModel <TViewModel>(UWPView, name);
            }
            else if (Device.RuntimePlatform == Device.macOS && macOSView != null)
            {
                container.RegisterForNavigationWithViewModel <TViewModel>(macOSView, name);
            }
            else if (otherView != null)
            {
                container.RegisterForNavigationWithViewModel <TViewModel>(otherView, name);
            }
            else
            {
                container.RegisterForNavigation <TView, TViewModel>(name);
            }
        }
Exemple #7
0
        /// <summary>
        /// Registers a Page for navigation.
        /// </summary>
        /// <typeparam name="TView">The Type of Page to register</typeparam>
        /// <param name="container"><see cref="ICodeBrixContainer"/> used to register type for Navigation.</param>
        /// <param name="name">The unique name to register with the Page</param>
        public static void RegisterForNavigation <TView>(this ICodeBrixContainer container, string name = null) where TView : Page
        {
            var viewType = typeof(TView);

            if (string.IsNullOrWhiteSpace(name))
            {
                name = viewType.Name;
            }

            container.RegisterForNavigation(viewType, name);
        }
Exemple #8
0
 protected override void RegisterTypes(ICodeBrixContainer container)
 {
     container.RegisterForNavigation <MainPage>();
     container.RegisterForNavigation <NavigatingAwareTabbedPage>();
     container.RegisterForNavigation <EventInitializingTabbedPage>();
     container.RegisterForNavigation <DynamicTabbedPage>(() => new DynamicTabbedPage(container));
     container.RegisterForNavigation <ViewA>();
     container.RegisterForNavigation <ViewB>();
     container.RegisterForNavigation <ViewC>();
 }
Exemple #9
0
        private static void RegisterForNavigationWithViewModel <TViewModel>(this ICodeBrixContainer container, Type viewType, string name)
            where TViewModel : class
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = viewType.Name;
            }

            ViewModelLocationProvider.Register(viewType.ToString(), typeof(TViewModel));

            container.RegisterForNavigation(viewType, name);
        }
Exemple #10
0
        /// <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="ICodeBrixContainer"/> 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 View name.</param>
        /// <param name="platforms"></param>
        public static void RegisterForNavigationOnPlatform <TView, TViewModel>(this ICodeBrixContainer container, string name, params Prism.IPlatform[] platforms)
            where TView : Page
            where TViewModel : class
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = typeof(TView).Name;
            }

            foreach (var platform in platforms)
            {
                if (Device.RuntimePlatform == platform.RuntimePlatform.ToString())
                {
                    container.RegisterForNavigationWithViewModel <TViewModel>(platform.ViewType, name);
                }
            }

            container.RegisterForNavigation <TView, TViewModel>(name);
        }
Exemple #11
0
 protected override void RegisterTypes(ICodeBrixContainer container)
 {
     container.RegisterForNavigation <MainPage>();
 }
 public override void RegisterTypes(ICodeBrixContainer container)
 {
     //Perform any type or page or service registration required by the module here
     container.RegisterForNavigation <SamplePage>();
 }