예제 #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);
        }
예제 #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);
        }
예제 #3
0
        public void EnsureLoaded()
        {
            if (_loaded)
            {
                return;
            }

            _loaded = true;

            Mvx.LazyConstructAndRegisterSingleton(typeof(IMvxRoutingService), () =>
            {
                MvxRoutingService.LoadRoutes(_configuration.SourceAssemblies);
                return(Mvx.IocConstruct <MvxRoutingService>());
            });
        }
예제 #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
        }
예제 #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());
        }
예제 #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();
        }
예제 #7
0
        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();
        }
예제 #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>();
 }
예제 #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);
        }
예제 #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>();
 }
예제 #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");
        }
예제 #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();
 }
예제 #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();
        }
예제 #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
        }
예제 #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>();
        }
예제 #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();
 }
예제 #17
0
파일: App.cs 프로젝트: covertops69/telling
        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>();
        }
예제 #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>();
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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());
        }
예제 #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);
        }
예제 #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>();
        }
예제 #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
        }
예제 #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);
        }
예제 #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>();
        }
예제 #29
0
 public void Load()
 {
     Mvx.LazyConstructAndRegisterSingleton(() => CrossFingerprint.Current);
 }
예제 #30
0
 protected virtual void RegisterViewTypeFinder()
 {
     Mvx.LazyConstructAndRegisterSingleton <IMvxViewModelTypeFinder, MvxViewModelViewTypeFinder>();
 }