コード例 #1
0
        public App()
        {
            InitializeComponent();

            var currentAssembly = Assembly.GetExecutingAssembly();

            var navigationHelper = new FormsNavigationHelper();

            navigationHelper.RegisterViewsInAssembly(currentAssembly);

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterInstance <INavigationHelper>(navigationHelper);


            containerBuilder.RegisterAssemblyTypes(currentAssembly)
            .Where(x => x.IsSubclassOf(typeof(Page)));

            containerBuilder.RegisterAssemblyTypes(currentAssembly)
            .Where(x => x.IsSubclassOf(typeof(ViewModelBase)));

            var container = containerBuilder.Build();

            Resolver.SetResolver(new AutofacResolver(container));

            navigationHelper.SetRootView(nameof(MainTabbedView), false);
        }
コード例 #2
0
        public App()
        {
            InitializeComponent();

            var currentAssembly = Assembly.GetExecutingAssembly();

            var navigationHelper = new FormsNavigationHelper();

            navigationHelper.RegisterViewsInAssembly(currentAssembly);

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterInstance <INavigationHelper>(navigationHelper);

            containerBuilder.RegisterAssemblyTypes(currentAssembly)
            .Where(x => x.IsSubclassOf(typeof(Page)));

            containerBuilder.RegisterAssemblyTypes(currentAssembly)
            .Where(x => x.IsSubclassOf(typeof(CoreViewModel)));

            containerBuilder.RegisterType <NotificationManager>().As <INotificationService>().SingleInstance();

            containerBuilder.RegisterInstance <ILocalizationService>(new ResourceManagerLocalizationService(AppResource.ResourceManager, CultureInfo.InvariantCulture));

            var container = containerBuilder.Build();

            Resolver.SetResolver(new AutofacResolver(container));

            navigationHelper.SetRootView(nameof(MainPage), false);
        }