Esempio n. 1
0
        public void TryResolve_CircularLazyRegistration_ReturnsFalse()
        {
            MvxSingleton.ClearAllSingletons();
            var instance = MvxIoCProvider.Initialize();

            Mvx.LazyConstructAndRegisterSingleton <IA, A>();
            Mvx.LazyConstructAndRegisterSingleton <IB, B>();
            Mvx.LazyConstructAndRegisterSingleton <IC, C>();

            IA  a;
            var result = Mvx.TryResolve(out a);

            Assert.False(result);
            Assert.Null(a);
        }
Esempio n. 2
0
        public void TryResolve_NonCircularRegistration_ReturnsTrue()
        {
            MvxSingleton.ClearAllSingletons();
            var instance = MvxSimpleIoCContainer.Initialize();

            Mvx.LazyConstructAndRegisterSingleton <IA, A>();
            Mvx.LazyConstructAndRegisterSingleton <IB, B>();
            Mvx.LazyConstructAndRegisterSingleton <IC, C2>();

            IA  a;
            var result = Mvx.TryResolve(out a);

            Assert.IsTrue(result);
            Assert.IsNotNull(a);
        }
Esempio n. 3
0
        public void EnsureLoaded()
        {
            if (_loaded)
            {
                return;
            }

            _loaded = true;

            Mvx.LazyConstructAndRegisterSingleton(typeof(IMvxRoutingService), () =>
            {
                MvxRoutingService.LoadRoutes(_configuration.SourceAssemblies);
                return(Mvx.IocConstruct <MvxRoutingService>());
            });
        }
Esempio n. 4
0
        public WinAnalyticsService(GAConfiguration configuration)
            : base(configuration)
        {
            Mvx.LazyConstructAndRegisterSingleton <IVersion>(() => new AppVersionImpl());
            _version = Mvx.Resolve <IVersion>();

            _sharedTracker            = AnalyticsManager.Current.CreateTracker(configuration.TrackingId);
            _sharedTracker.AppVersion = _version.Version;
            _sharedTracker.AppName    = configuration.AppName;
            _sharedTracker.AppId      = configuration.AppId;
            AnalyticsManager.Current.DispatchPeriod           = TimeSpan.FromSeconds(configuration.DispatchInterval);
            AnalyticsManager.Current.ReportUncaughtExceptions = true;
#if DEBUG
            AnalyticsManager.Current.IsDebug = true;
#endif
        }
Esempio n. 5
0
        public void Load()
        {
            Mvx.ConstructAndRegisterSingleton <IFetcherLoggerService, FetcherLoggerService>();
            Mvx.ConstructAndRegisterSingleton <IFetcherWebService, FetcherWebService>();
            Mvx.ConstructAndRegisterSingleton <IFetcherRepositoryStoragePathService, FetcherRepositoryStoragePathService>();
            Mvx.LazyConstructAndRegisterSingleton <IFetcherRepositoryService>(() => new FetcherRepositoryService(Mvx.Resolve <IFetcherLoggerService>(), () => CreateConnection(Mvx.Resolve <IFetcherRepositoryStoragePathService>())));
            Mvx.LazyConstructAndRegisterSingleton <IFetcherService>(() => new FetcherService(Mvx.Resolve <IFetcherWebService>(), Mvx.Resolve <IFetcherRepositoryService>(), Mvx.Resolve <IFetcherLoggerService>()));

            // Force construction of singletons
            var repository = Mvx.Resolve <IFetcherRepositoryService>() as FetcherRepositoryService;

            Mvx.Resolve <IFetcherService>();

            // Ensure database tables are created
            Task.Run(async() => await repository.Initialize());
        }
Esempio n. 6
0
        protected override void InitializeFirstChance()
        {
            base.InitializeFirstChance();

            Mvx.LazyConstructAndRegisterSingleton <IConnectivity, ConnectivityImplementation>();
            Mvx.LazyConstructAndRegisterSingleton <IDialogService, DialogService>();
            Mvx.LazyConstructAndRegisterSingleton <IOneDriveAuthenticator, OneDriveAuthenticator>();
            Mvx.LazyConstructAndRegisterSingleton <IProtectedData, ProtectedData>();
            Mvx.LazyConstructAndRegisterSingleton <ITileManager, TileManager>();
            Mvx.LazyConstructAndRegisterSingleton <IAppInformation, AppInformation>();
            Mvx.LazyConstructAndRegisterSingleton <IStoreOperations, StoreOperations>();
            Mvx.LazyConstructAndRegisterSingleton <ISettings, Settings>();
            Mvx.LazyConstructAndRegisterSingleton <IBackgroundTaskManager, BackgroundTaskManager>();

            DependencyRegistrator.RegisterDependencies();
        }
        protected override void InitializeFirstChance()
        {
            Log.Info(".TrackMe", DateTime.Now + ": Setup called");

            CreatableTypes(typeof(FormsApp).Assembly)
            .EndingWith("Service")
            .AsInterfaces().ToList()
            .RegisterAsLazySingleton();

            Mvx.LazyConstructAndRegisterSingleton <ISendPositionService, SendPositionService>();
            Mvx.LazyConstructAndRegisterSingleton <IShareService, ShareService>();
            Mvx.LazyConstructAndRegisterSingleton <ISettings, Settings>();
            Mvx.LazyConstructAndRegisterSingleton <ILocalize, Localize>();

            base.InitializeFirstChance();
        }
Esempio n. 8
0
 protected override void InitializePlatformServices()
 {
     base.InitializePlatformServices();
     Mvx.LazyConstructAndRegisterSingleton <IInsightsService, TouchInsightsService>();
     Mvx.LazyConstructAndRegisterSingleton <IGeoLocationWatcher, TouchGeolocationWatcher>();
     Mvx.LazyConstructAndRegisterSingleton <IMotionActivity, TouchMotionActivity>();
     Mvx.LazyConstructAndRegisterSingleton <IPlatform, TouchPlatform>();
     Mvx.LazyConstructAndRegisterSingleton <INotificationSender, TouchNotificationSender>();
     Mvx.LazyConstructAndRegisterSingleton <ITextToSpeechService, TouchTextToSpeechService>();
     Mvx.LazyConstructAndRegisterSingleton <ISpeechToTextService, TouchSpeechToTextService>();
     Mvx.LazyConstructAndRegisterSingleton <IStoredSettingsBase, TouchStoredSettingsBase>();
     Mvx.ConstructAndRegisterSingleton <IFacebookLoginService, TouchFacebookLoginService>();
     Mvx.LazyConstructAndRegisterSingleton <IFileManager, TouchFileManager>();
     Mvx.LazyConstructAndRegisterSingleton <IGPlusLoginService, TouchGPlusLoginService>();
     Mvx.LazyConstructAndRegisterSingleton <IHttpClientHandlerService, TouchHttpClientHandlerService>();
     Mvx.LazyConstructAndRegisterSingleton <ICreditCardScanService, TouchCreditCardScanService>();
 }
Esempio n. 9
0
        public void TryResolve_ParameterConstructors_CreatesParametersUsingIocResolution()
        {
            MvxSingleton.ClearAllSingletons();
            var instance = MvxIoCProvider.Initialize();

            Mvx.RegisterType <IB, B>();
            Mvx.LazyConstructAndRegisterSingleton <IC, C2>();
            Mvx.RegisterType <IA, A>();

            IA  a1;
            var result = Mvx.TryResolve(out a1);

            Assert.True(result);
            Assert.NotNull(a1);
            Assert.NotNull(a1.B);
            Assert.IsType <B>(a1.B);
        }
Esempio n. 10
0
 protected override void InitializePlatformServices()
 {
     base.InitializePlatformServices();
     Mvx.LazyConstructAndRegisterSingleton <IInsightsService, DroidInsightsService>();
     Mvx.LazyConstructAndRegisterSingleton <IGeoLocationWatcher, DroidGeolocationWatcher>();
     Mvx.LazyConstructAndRegisterSingleton <IMotionActivity, DroidMotionActivity>();
     Mvx.LazyConstructAndRegisterSingleton <INotificationSender, DroidNotificationSender>();
     Mvx.LazyConstructAndRegisterSingleton <IPlatform, DroidPlatform>();
     Mvx.LazyConstructAndRegisterSingleton <ITextToSpeechService, DroidTextToSpeechService>();
     Mvx.LazyConstructAndRegisterSingleton <ISpeechToTextService, DroidSpeechToTextService>();
     Mvx.LazyConstructAndRegisterSingleton <IStoredSettingsBase, DroidStoredSettingsBase>();
     Mvx.LazyConstructAndRegisterSingleton <IGPlusLoginService, DroidGPlusLoginService>();
     Mvx.LazyConstructAndRegisterSingleton <IHttpClientHandlerService, DroidHttpClientHandlerService>();
     Mvx.LazyConstructAndRegisterSingleton <IFileManager, DroidFileManager>();
     Mvx.ConstructAndRegisterSingleton <IFacebookLoginService, DroidFacebookLoginService>();
     Mvx.RegisterType <ICalendarDialog, CalendarDialog>();
 }
Esempio n. 11
0
        public override void Initialize()
        {
            Mvx.RegisterSingleton <IMenuConfigService>(() => new MenuConfigService());
            Mvx.LazyConstructAndRegisterSingleton <IMenuVmService, MenuVmService>();

            #region VMs registration

            var vmLookupService = Mvx.Resolve <IViewModelLookupService>();

            vmLookupService.Register <IMenuViewModel>(typeof(MenuViewModel));

            #endregion

            RegisterAppStart <ViewModels.MenuViewModel>();

            MvxTrace.Trace(MvxTraceLevel.Diagnostic, "Menu module is loaded");
        }
Esempio n. 12
0
 protected override void InitializeFirstChance()
 {
     Mvx.LazyConstructAndRegisterSingleton <ISqlite, SqliteDroid>();
     Mvx.LazyConstructAndRegisterSingleton <IDialogService, DialogService>();
     Mvx.LazyConstructAndRegisterSingleton <IAzureDatabase, AzureDatabase>();
     Mvx.LazyConstructAndRegisterSingleton <ICalendarTableDatabase, CalendarTableDatabaseAzure>();
     Mvx.LazyConstructAndRegisterSingleton <ICommunityPostTableDatabase, CommunityPostTableDatabaseAzure>();
     Mvx.LazyConstructAndRegisterSingleton <IConsultTableDatabase, ConsultTableDatabaseAzure>();
     Mvx.LazyConstructAndRegisterSingleton <IExerciseEnteredTableDatabase, ExerciseEnteredTableDatabaseAzure>();
     Mvx.LazyConstructAndRegisterSingleton <IExerciseTableDatabase, ExerciseTableDatabaseAzure>();
     Mvx.LazyConstructAndRegisterSingleton <IFoodEnteredTableDatabase, FoodEnteredTableDatabaseAzure>();
     Mvx.LazyConstructAndRegisterSingleton <IFoodsTableDatabase, FoodsTableDatabaseAzure>();
     Mvx.LazyConstructAndRegisterSingleton <IMeetupsTableDatabase, MeetupsTableDatabaseAzure>();
     Mvx.LazyConstructAndRegisterSingleton <IUserTableDatabase, UserTableDatabaseAzure>();
     Mvx.LazyConstructAndRegisterSingleton <ILocationsDatabase, LocationDatabaseAzure>();
     Mvx.LazyConstructAndRegisterSingleton <IGeoCoder, GeoCoder>();
     base.InitializeFirstChance();
 }
Esempio n. 13
0
        public override void Initialize()
        {
            CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            Mvx.LazyConstructAndRegisterSingleton <IMvxMessenger, MvxMessengerHub>();

            Mvx.LazyConstructAndRegisterSingleton <ISendBirdResultsHandler, SendBirdResultsHandler>();
            Mvx.LazyConstructAndRegisterSingleton <IContext, Context>();

            RegisterAppStart <LoginViewModel>();

            var _sendbird = Mvx.Resolve <ISendbirdConnectionService>();

            _sendbird.GetAPI().InitWithApplicationId();
        }
Esempio n. 14
0
        public override void Initialize()
        {
            CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();
            RegisterAppStart(new CustomAppStart());

            Mvx.LazyConstructAndRegisterSingleton <IWaypointChecker, WaypointChecker>();
            Mvx.LazyConstructAndRegisterSingleton <IDistanceChecker, DistanceChecker>();
            Mvx.LazyConstructAndRegisterSingleton <ITrackFacade, TrackFacade>();
            Mvx.LazyConstructAndRegisterSingleton <IPaymentProcessing, PaymentProcessing>();
#if DEBUG
            Mvx.LazyConstructAndRegisterSingleton <IGeoLocationWatcher, MockGeoLocation>();
            Mvx.LazyConstructAndRegisterSingleton <IMotionActivity, MockGeoLocation>();
            Mvx.LazyConstructAndRegisterSingleton <IMockGeoLocation, MockGeoLocation>();
#endif
        }
Esempio n. 15
0
        public override void Initialize()
        {
            CreatableTypes().
            EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            CreatableTypes().
            EndingWith("Repository")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            Mvx.LazyConstructAndRegisterSingleton <IMvxMessenger, MvxMessengerHub>();
            RegisterNavigationServiceAppStart <WeatherTabsViewModel>();

            //Interfaces linken met de service (GPS)
            Mvx.ConstructAndRegisterSingleton <ILocationService, LocationService>();
            Mvx.ConstructAndRegisterSingleton <INotificationService, NotificationService>();
        }
Esempio n. 16
0
 protected override void InitializeFirstChance()
 {
     Mvx.LazyConstructAndRegisterSingleton <IAppDataFileService, AppDataFileService>();
     Mvx.LazyConstructAndRegisterSingleton <IAppPackageService, AppPackageService>();
     Mvx.LazyConstructAndRegisterSingleton <IAppPackageFileService, AppPackageFileService>();
     Mvx.LazyConstructAndRegisterSingleton <ITabProvider, TabProvider>();
     Mvx.LazyConstructAndRegisterSingleton <IFilePickerService, FilePickerService>();
     Mvx.LazyConstructAndRegisterSingleton <ITimerService, TimerService>();
     Mvx.LazyConstructAndRegisterSingleton <IFeedbackService, FeedbackService>();
     Mvx.LazyConstructAndRegisterSingleton <IAppNotificationService, AppNotificationService>();
     Mvx.LazyConstructAndRegisterSingleton <IPasswordVaultService, PasswordVaultService>();
     Mvx.LazyConstructAndRegisterSingleton <ISettingsService, SettingsService>();
     Mvx.LazyConstructAndRegisterSingleton <IDialogService, DialogService>();
     Mvx.LazyConstructAndRegisterSingleton <ISfxPlayerService, UwpSfxPlayerService>();
     Mvx.LazyConstructAndRegisterSingleton <IAppNotificationService, AppNotificationService>();
     Mvx.LazyConstructAndRegisterSingleton <IMemoryService, MemoryService>();
     Mvx.LazyConstructAndRegisterSingleton <IDataMigrationProvider, DataMigrationProvider>();
     EnsureLargeSettingsFolderCreated();
     base.InitializeFirstChance();
 }
Esempio n. 17
0
        public override void Initialize()
        {
            CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            //CreatableTypes()
            //    .EndingWith("Manager")
            //    .AsInterfaces()
            //    .RegisterAsLazySingleton();

            //Mvx.LazyConstructAndRegisterSingleton(() => new StateMachine<State, Trigger>(State.Launch));
            //ConfigureStateMachine();

            Mvx.RegisterType <IValidateRequest, ValidateRequest>();
            Mvx.LazyConstructAndRegisterSingleton <IMvxMessenger, MvxMessengerHub>();

            RegisterAppStart <SessionListingViewModel>();
        }
Esempio n. 18
0
        public override void Initialize()
        {
            BlobCache.ApplicationName = "VirtualRisks";
            CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            Mvx.LazyConstructAndRegisterSingleton <IMvxMessenger, MvxMessengerHub>();

            Mvx.RegisterSingleton <IUserDialogs>(() => UserDialogs.Instance);
            Mvx.RegisterSingleton <ICommonViewResource>(new CommonViewResource());
            Mvx.RegisterSingleton <IGamePageViewResource>(new GamePageViewResource());
            InitRestClient();
            if (Settings.RequireLogin())
            {
                Settings.Clear();
            }
            RegisterAppStart <ViewModels.MainViewModel>();
        }
Esempio n. 19
0
        public void TryResolve_Dynamic_ReturnsDifferentInstanceEachTime()
        {
            MvxSingleton.ClearAllSingletons();
            var instance = MvxIoCProvider.Initialize();

            Mvx.LazyConstructAndRegisterSingleton <IB, B>();
            Mvx.LazyConstructAndRegisterSingleton <IC, C2>();
            Mvx.RegisterType <IA, A>();

            var previous = new Dictionary <IA, bool>();

            for (int i = 0; i < 100; i++)
            {
                IA  a1;
                var result = Mvx.TryResolve(out a1);
                Assert.True(result);
                Assert.False(previous.ContainsKey(a1));
                Assert.Equal(i, previous.Count);
                previous.Add(a1, true);
            }
        }
Esempio n. 20
0
        public DroidAnalyticsService(GAConfiguration configuration)
            : base(configuration)
        {
            Mvx.LazyConstructAndRegisterSingleton <IVersion>(() => new AppVersionImpl());
            _version = Mvx.Resolve <IVersion>();
            configuration.AppVersion = _version.Version;

            IAndroidApp app = Mvx.Resolve <IAndroidApp>();

            if (app != null)
            {
                var context   = (Context)app.TopActivity;
                var analytics = GoogleAnalytics.GetInstance(context);
                analytics.SetLocalDispatchPeriod((int)configuration.DispatchInterval);
                mTracker = analytics.NewTracker(configuration.TrackingId);
                mTracker.SetAppId(configuration.AppId);
                mTracker.SetAppName(configuration.AppName);
                mTracker.SetAppVersion(configuration.AppVersion);
                mTracker.EnableExceptionReporting(true);
            }
        }
Esempio n. 21
0
        public iOSAnalyticsService(GAConfiguration configuration)
            : base(configuration)
        {
            Mvx.LazyConstructAndRegisterSingleton <IVersion>(() => new AppVersionImpl());
            _version = Mvx.Resolve <IVersion>();

            Gai.SharedInstance.DispatchInterval        = configuration.DispatchInterval;
            Gai.SharedInstance.TrackUncaughtExceptions = true;

            #if DEBUG
            // TODO uncomment before Release
            //Gai.SharedInstance.DryRun = true;
            #endif

            if (!string.IsNullOrWhiteSpace(configuration.TrackingId))
            {
                _sharedTracker = Gai.SharedInstance.GetTracker("Atelier", configuration.TrackingId);
                _sharedTracker.Set("&appId", configuration.AppId);
                _sharedTracker.Set("&appName", configuration.AppName);
                _sharedTracker.Set("&appVersion", _version.Version);
            }
        }
Esempio n. 22
0
        public void TryResolve_NonLazySingleton_ReturnsSameSingletonEachTime()
        {
            MvxSingleton.ClearAllSingletons();
            var instance = MvxIoCProvider.Initialize();

            Mvx.LazyConstructAndRegisterSingleton <IB, B>();
            Mvx.LazyConstructAndRegisterSingleton <IC, C2>();
            Mvx.ConstructAndRegisterSingleton <IA, A>();

            IA  a0;
            var result = Mvx.TryResolve(out a0);

            Assert.True(result);
            Assert.NotNull(a0);

            for (int i = 0; i < 100; i++)
            {
                IA a1;
                result = Mvx.TryResolve(out a1);
                Assert.True(result);
                Assert.Equal(a0, a1);
            }
        }
Esempio n. 23
0
        protected override void InitializeLastChance()
        {
            base.InitializeLastChance();

            Mvx.LazyConstructAndRegisterSingleton <ILoggerService>(() => new LoggerService(ApplicationContext));
            Mvx.ConstructAndRegisterSingleton <IDialogService, DialogService>();

            Mvx.ConstructAndRegisterSingleton <IFetcherLoggerService, FetcherLoggerService>();
            Mvx.ConstructAndRegisterSingleton <IFetcherWebService, FetcherWebService>();
            Mvx.ConstructAndRegisterSingleton <IFetcherRepositoryStoragePathService, FetcherRepositoryStoragePathService>();
            Mvx.LazyConstructAndRegisterSingleton <IFetcherRepositoryService>(() => new FetcherRepositoryService(Mvx.Resolve <IFetcherLoggerService>(), () => CreateConnection(Mvx.Resolve <IFetcherRepositoryStoragePathService>())));
            Mvx.LazyConstructAndRegisterSingleton <IFetcherService>(() => new FetcherService(Mvx.Resolve <IFetcherWebService>(), Mvx.Resolve <IFetcherRepositoryService>(), Mvx.Resolve <IFetcherLoggerService>()));

            // Force construction of singletons
            var repository = Mvx.Resolve <IFetcherRepositoryService>() as FetcherRepositoryService;

            Mvx.Resolve <IFetcherService>();

            // Ensure database tables are created
            repository.Initialize().Wait();
            var debug = 42;
            //Task.Run(async () => await repository.Initialize());
        }
Esempio n. 24
0
        public override void Initialize()
        {
            CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            // Register localization services
            var builder = new TextProviderBuilder();

            Mvx.RegisterSingleton <IMvxTextProviderBuilder>(builder);
            Mvx.RegisterSingleton <IMvxTextProvider>(builder.TextProvider);

            // Construct custom application start object
            Mvx.ConstructAndRegisterSingleton <IMvxAppStart, AppStart>();
            var appStart = Mvx.Resolve <IMvxAppStart>();

            //Enregistrer les services : le web service
            Mvx.LazyConstructAndRegisterSingleton <IWebService>(() => new WebService());

            // register the appstart object
            RegisterAppStart(appStart);
        }
Esempio n. 25
0
        public override void Initialize()
        {
            CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            Mvx.LazyConstructAndRegisterSingleton <IMvxMessenger, MvxMessengerHub>();
            Mvx.LazyConstructAndRegisterSingleton <IDataAnalyticsService, DataAnalyticsService>();
            Mvx.LazyConstructAndRegisterSingleton <ILocationService, LocationService>();

            ISNTPService sntpService = new SNTPService();

            Mvx.RegisterSingleton <ISNTPService>(sntpService);

            IGLOSAWebService gLOSAWebService = new GLOSAWebService(Mvx.Resolve <IDataAnalyticsService>());

            Mvx.RegisterSingleton <IGLOSAWebService>(gLOSAWebService);

            Mvx.RegisterType <IVehicleService, VehicleService>();

            RegisterAppStart <SpeedAdvisoryViewModel>();
        }
Esempio n. 26
0
        protected override void InitializeIoC()
        {
            base.InitializeIoC();

            Mvx.LazyConstructAndRegisterSingleton <IMvxFormsPageLoader, ViewLoader>();

            // plugins services
            Mvx.LazyConstructAndRegisterSingleton(() => UserDialogs.Instance);
            Mvx.LazyConstructAndRegisterSingleton(() => CrossSettings.Current);

            // common services
            Mvx.LazyConstructAndRegisterSingleton <IPlatformSpecificCalls, PlatformSpecificCalls>();
            Mvx.LazyConstructAndRegisterSingleton <ILocalNotificationService, LocalNotificationService>();

            // shared services
            Mvx.LazyConstructAndRegisterSingleton <ILocalizationInfo, LocalizationInfo>();

            InitializePlatformSpecificIoC();
#if !DEBUG
            //Identify user for tracking
            Track.TryToIdentify();
#endif
        }
Esempio n. 27
0
        public override void Initialize()
        {
            //SHOW: Registering services as singeltons
            //search for all classes (ending with 'Service') and register them as LazySingleton
            CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();


            //Register API Service
            //Mvx.RegisterSingleton<IXamarinMVVMSampleWebAPIService>(new XamarinMVVMSampleWebAPIService());
            //*alernative - useful when the registered type requires constructor dependency injection
            //Mvx.ConstructAndRegisterSingleton<IXamarinMVVMSampleWebAPIService,XamarinMVVMSampleWebAPIService>();

            //*lazy singleton - not created untill someone asks for it
            //Mvx.RegisterSingleton<IXamarinMVVMSampleWebAPIService>(() => new XamarinMVVMSampleWebAPIService());
            //*lazy singleton registration -useful when the registered type requires constructor dependency injection
            //SHOW: Explicit registration of a service
            Mvx.LazyConstructAndRegisterSingleton <IXamarinMVVMSampleWebAPI, XamarinMVVMSampleWebAPI>();


            // every time someone needs an IFoo they will get a new one
            //Mvx.RegisterType<IFoo, Foo>();



            //SHOW: Custom AppStart object
            // Construct custom application start object
            Mvx.ConstructAndRegisterSingleton <IMvxAppStart, AppStart>();

            // request a reference to the constructed appstart object
            var appStart = Mvx.Resolve <IMvxAppStart>();

            // register the appstart object
            RegisterAppStart(appStart);
        }
Esempio n. 28
0
        public override void Initialize()
        {
            CreatableTypes()
            .EndingWith("Repository")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            /* CreatableTypes()
             *   .EndingWith("ConnectionFactory")
             *   .AsInterfaces()
             *   .RegisterAsLazySingleton();
             *
             * /*  CreatableTypes()
             *   .EndingWith("Service")
             *   .AsInterfaces()
             *   .RegisterAsLazySingleton();
             */

            // RegisterAppStart<MvvmCross.Core.ViewModels.FoodsViewModel>();
            Mvx.RegisterType <IDbConnectionManager, DbConnectionManager>();

            Mvx.LazyConstructAndRegisterSingleton <IFavorRepository, FavorRepository>();
            Mvx.LazyConstructAndRegisterSingleton <IChannelRepository, ChannelRepository>();
            //RegisterSingleton<ILocalUserRepository, LocalUserRepository>();


            var container = Mvx.Resolve <IDbConnectionManager>();
            var f         = container.GetConnection();

            f.CreateTableAsync <FavoriteVideos>();
            f.CreateTableAsync <Channels>();
            // var d = container.GetConnection();

            // d.CreateTablesAsync<FavoriteVideos, Channels>(SQLite.CreateFlags.ImplicitPK | SQLite.CreateFlags.AutoIncPK); ;
            //  RegisterAppStart<ViewModels.FoodRecyclerViewModel>();
        }
Esempio n. 29
0
 public void Load()
 {
     Mvx.LazyConstructAndRegisterSingleton(() => CrossFingerprint.Current);
 }
Esempio n. 30
0
 protected virtual void RegisterViewTypeFinder()
 {
     Mvx.LazyConstructAndRegisterSingleton <IMvxViewModelTypeFinder, MvxViewModelViewTypeFinder>();
 }