public static IMvxIoCProvider RegisterDependencies(IMvxIoCProvider provider) { provider.RegisterSingleton <IUserDialogs>(() => UserDialogs.Instance); provider.ConstructAndRegisterSingleton(typeof(GenderPredictionService)); provider.ConstructAndRegisterSingleton(typeof(AgePredictionService)); return(provider); }
private void InitializeServices(IMvxIoCProvider provider) { provider.ConstructAndRegisterSingleton <IRequestProvider, RequestProvider>(); provider.ConstructAndRegisterSingleton <IOpenWeatherApi, OpenWeatherApi>(); provider.ConstructAndRegisterSingleton <IWeatherViewService, WeatherViewService>(); provider.RegisterSingleton <IUserDialogs>(() => UserDialogs.Instance); }
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> >(); }
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(); }
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); } }
public static IMvxIoCProvider RegisterDependencies(IMvxIoCProvider provider) { provider.RegisterSingleton <IUserDialogs>(() => UserDialogs.Instance); provider.ConstructAndRegisterSingleton <IClientService, ClientService>(); return(provider); }