public App() { InitializeComponent(); var currentAssembly = Assembly.GetExecutingAssembly(); var navigationHelper = new FormsNavigationHelper(); navigationHelper.RegisterViewsInAssembly(currentAssembly); var container = TinyIoCContainer.Current; container.Register <IAppConfigService, AppConfigService>(); container.Register <IDeviceInfoService, DeviceInfoService>(); container.Register <IGeolocationService, GeolocationService>(); container.Register <IIoTDeviceClientService, IoTDeviceClientService>(); container.Register <MainPage>(); container.Register <MainViewModel>(); Resolver.SetResolver(new TinyIoCResolver()); TinyMvvm.Forms.TinyMvvm.Initialize(); MainPage = new MainPage(); }
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); }
static IContainer CreateContainer() { var builder = new ContainerBuilder(); // Set up TinyMVVM var currentAssembly = Assembly.GetExecutingAssembly(); var navigationHelper = new FormsNavigationHelper(); navigationHelper.RegisterViewsInAssembly(currentAssembly); builder.RegisterInstance <INavigationHelper>(navigationHelper); var appAssembly = typeof(App).GetTypeInfo().Assembly; builder.RegisterAssemblyTypes(appAssembly).Where(x => x.IsSubclassOf(typeof(Page))); builder.RegisterAssemblyTypes(appAssembly).Where(x => x.IsSubclassOf(typeof(BaseViewModel))); //Register additional services builder.RegisterType <AnalyticsService>().As <IAnalyticsService>().SingleInstance(); // TODO: One day... builder.RegisterType<MsalAuthService>().As<IAuthService>().SingleInstance(); builder.RegisterType <LiveAuthService>().As <IAuthService>().SingleInstance(); builder.RegisterType <MvpApiService>().As <IMvpApiService>().SingleInstance(); builder.RegisterType <LanguageService>().As <LanguageService>().SingleInstance(); return(builder.Build()); }
public App() { InitializeComponent(); var navigationHelper = new FormsNavigationHelper(this); navigationHelper.RegisterViewsInAssembly(Assembly.GetExecutingAssembly()); var builder = new ContainerBuilder(); builder.RegisterInstance <INavigationHelper>(navigationHelper); // ViewModels var coreAssembly = Assembly.Load(new AssemblyName("LeetPhotos.Core")); builder.RegisterAssemblyTypes(coreAssembly) .Where(x => x.Name.EndsWith("ViewModel", StringComparison.Ordinal)); builder.RegisterType <RestClient>().As <IRestClient>(); builder.RegisterType <PhotoService>().As <IPhotoService>(); builder.RegisterType <Command>().As <ICommand>(); var container = builder.Build(); Resolver.SetResolver(new AutofacResolver(container)); ViewModel.BeginInvokeOnMainThread = (action) => Device.BeginInvokeOnMainThread(action); NavigationHelper.Current.SetRootView("PhotosView"); ((Xamarin.Forms.NavigationPage)MainPage).On <Xamarin.Forms.PlatformConfiguration.iOS>().SetPrefersLargeTitles(true); }
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); }
public static void Init(Application app) { var builder = new ContainerBuilder(); Platform?.Init(builder); var navigation = new FormsNavigationHelper(); navigation.RegisterViewsInAssembly(Assembly.GetExecutingAssembly()); builder.RegisterType <Views.MainView>(); builder.RegisterType <FormsNavigationHelper>().As <INavigationHelper>(); builder.RegisterType <MediaProvider>().As <IMediaProvider>(); builder.RegisterType <MainViewModel>(); //builder.RegisterType<DefaultPredictor>().As<IPredictor>(); var container = builder.Build(); Resolver.SetResolver(new AutofacResolver(container)); TinyMvvm.Forms.TinyMvvm.Initialize(); var cache = TinyCacheHandler.Create("FileCache"); var fileStorage = new FileStorage(); var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); fileStorage.Initialize(path); cache.SetCacheStore(fileStorage); }
public App() { InitializeComponent(); // Register views var navigationHelper = new FormsNavigationHelper(this); /* navigationHelper.RegisterView<MainView>("MainView"); * navigationHelper.RegisterView<AboutView>("AboutView"); * navigationHelper.RegisterView<SettingsView>("SettingsView"); */ var asm = typeof(App).GetTypeInfo().Assembly; navigationHelper.RegisterViewsInAssembly(asm); MainPage = new NavigationPage(new MainView()); }