Exemple #1
0
        private static void ConfigureContainer(TinyIoCContainer container, IHaveMainPage mainApp)
        {
            var appInsights = new TelemetryClient(new TelemetryConfiguration("97e6fd64-c506-4830-9530-fbe9a7274326"));

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.NSLog()
                         .WriteTo.ApplicationInsights(
                appInsights,
                TelemetryConverter.Traces,
                restrictedToMinimumLevel: LogEventLevel.Information)
                         .WriteTo.Debug(restrictedToMinimumLevel: LogEventLevel.Information)
                         .CreateLogger();

            AppDomain.CurrentDomain.UnhandledException += (s, e) => LogUnhandled(e.ExceptionObject as Exception);
            TaskScheduler.UnobservedTaskException      += (s, e) => LogUnhandled(e.Exception);

            container.Register(Log.Logger);
            container.Register <IAuthorizer, Authorizer>();
            container.Register <IActionPresenter, ActionPresenter>();
            container.Register <IShare, HealthNerd.Services.Share>();
            container.Register <IClock>(SystemClock.Instance);
            container.Register <IFileManager, FileManager>(
                new FileManager(container.Resolve <IClock>(), FileSystem.CacheDirectory));
            container.Register <ISettingsStore, SettingsStore>();
            container.Register <IAnalytics>(new MultiAnalytics(
                                                new FirebaseAnalytics(),
                                                new AppInsightsAnalytics(appInsights)));
            container.Register <AuthorizeHealthCommand>();
            container.Register <ExportSpreadsheetCommand>();
            container.Register <IHealthStore>(new HealthStore(new HKHealthStore()));

            var navigator = new NavigationService(mainApp, new ViewLocator(), container);

            container.Register <MainPageViewModel>();
            container.Register <SettingsViewModel>();
            container.Register <ExportSettingsViewModel>();
            container.Register <OnboardingPageViewModel>();
            container.Register <OnboardingWelcomeViewModel>();
            container.Register <OnboardingWhatViewModel>();
            container.Register <OnboardingAuthViewModel>();
            container.Register <OnboardingSettingsViewModel>();
            container.Register <OnboardingFinishViewModel>();

            container.Register <INavigationService>(navigator);

            void LogUnhandled(Exception ex)
            {
                Log.Logger.Error(ex, "Unhandled exception");
                appInsights.TrackException(ex);
                appInsights.Flush();
            }
        }
 public NavigationService(IHaveMainPage presentationRoot, IViewLocator viewLocator, TinyIoCContainer container)
 {
     _presentationRoot = presentationRoot;
     _viewLocator      = viewLocator;
     _container        = container;
 }
 public NavigationService(IHaveMainPage presentationRoot, IViewLocator viewLocator)
 {
     _presentationRoot = presentationRoot;
     _viewLocator      = viewLocator;
 }