예제 #1
0
 public static IMvxIoCProvider RegisterDependencies(IMvxIoCProvider provider)
 {
     provider.RegisterSingleton <IUserDialogs>(() => UserDialogs.Instance);
     provider.ConstructAndRegisterSingleton(typeof(GenderPredictionService));
     provider.ConstructAndRegisterSingleton(typeof(AgePredictionService));
     return(provider);
 }
예제 #2
0
 private void InitializeServices(IMvxIoCProvider provider)
 {
     provider.ConstructAndRegisterSingleton <IRequestProvider, RequestProvider>();
     provider.ConstructAndRegisterSingleton <IOpenWeatherApi, OpenWeatherApi>();
     provider.ConstructAndRegisterSingleton <IWeatherViewService, WeatherViewService>();
     provider.RegisterSingleton <IUserDialogs>(() => UserDialogs.Instance);
 }
예제 #3
0
        private async Task InitializeDbAsync(IMvxIoCProvider provider)
        {
            ISQLite sqlite    = provider.Resolve <ISQLite>();
            var     dbContext = new DbAsyncContext(sqlite.GetDatabasePath(Consts.DatabaseName));
            await dbContext.ConnectToDatabase();

            provider.RegisterSingleton <IDbAsyncContext>(dbContext);

            provider.ConstructAndRegisterSingleton <
                IDatabaseService <WeatherDbItem>, DatabaseService <WeatherDbItem, int> >();
            provider.ConstructAndRegisterSingleton <
                IDatabaseService <CountryDbItem>, DatabaseService <CountryDbItem, int> >();
        }
예제 #4
0
        public override void Initialize()
        {
            _ioC = Mvx.IoCProvider;

            _ioC.RegisterSingleton <ISettings>(CrossSettings.Current);
            _ioC.ConstructAndRegisterSingleton <IAppSettings, AppSettings>();

            _ioC.RegisterSingleton <IUserDialogs>(() => UserDialogs.Instance);

            _ioC.ConstructAndRegisterSingleton <IRequestProvider, RequestProvider>();

            _ioC.ConstructAndRegisterSingleton <ICostManagerService, CostManagerService>();

            StartViewModel();
        }
예제 #5
0
        public virtual void TryResolve_NonLazySingleton_ReturnsSameSingletonEachTime()
        {
            _iocProvider.LazyConstructAndRegisterSingleton <IB, B>();
            _iocProvider.LazyConstructAndRegisterSingleton <IC, C2>();
            _iocProvider.ConstructAndRegisterSingleton <IA, A>();

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

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

            for (var i = 0; i < 100; i++)
            {
                result = _iocProvider.TryResolve(out IA a1);
                Assert.True(result);
                Assert.Equal(a0, a1);
            }
        }
예제 #6
0
 public static IMvxIoCProvider RegisterDependencies(IMvxIoCProvider provider)
 {
     provider.RegisterSingleton <IUserDialogs>(() => UserDialogs.Instance);
     provider.ConstructAndRegisterSingleton <IClientService, ClientService>();
     return(provider);
 }