Beispiel #1
0
        public static void UseMultiple()
        {
            var config = new ResolverConfig();

            config
            .Bind <IConnectionFactory>()
            .ToConstant(new CallbackConnectionFactory(() => new SqliteConnection("Data Source=:memory:")))
            .InSingletonScope()
            .Named(string.Empty);
            config
            .Bind <IConnectionFactory>()
            .ToConstant(new CallbackConnectionFactory(() => new SqliteConnection("Data Source=:memory:")))
            .InSingletonScope()
            .Named("Sub");

            config.AddAccessorFactory(c =>
            {
                c.UseExecutor <ExecutorImpl>();
                c.UseConnectionManager(k => new NamedResolverConnectionManager(k));
            });

            config.Bind <Service>().ToSelf().InSingletonScope();

            var resolver = config.ToResolver();

            var service = resolver.Get <Service>();

            service.Action();
        }
Beispiel #2
0
        private SmartResolver CreateResolver(IComponentProvider provider)
        {
            var config = new ResolverConfig()
                         .UseAutoBinding()
                         .UseArrayBinding()
                         .UseAssignableBinding()
                         .UsePropertyInjector()
                         .UsePageContextScope();

            config.UseXamarinFormsComponents(adapter =>
            {
                adapter.AddDialogs();
                adapter.AddPopupNavigator();
                adapter.AddJsonSerializer();
                adapter.AddSettings();

                // Custom
                adapter.UsePopupPageFactory <PopupPageFactory>();
            });

            config.BindSingleton <INavigator>(_ => navigator);

            config.BindSingleton <ApplicationState>();

            config.BindSingleton <Configuration>();
            config.BindSingleton <Session>();

            config.BindSingleton <IAttachableBarcodeReader, AttachableEntryBarcodeReader>();

            provider.RegisterComponents(config);

            return(config.ToResolver());
        }
Beispiel #3
0
        public App(IComponentProvider provider)
        {
            InitializeComponent();

            var config = new ResolverConfig();

            RegisterComponents(config);
            provider.RegisterComponents(config);
            Resolver = config.ToResolver();

            MainPage = new NavigationPage {
                BarBackgroundColor = (Color)Resources["MetroBlueDark"]
            };

            var navigationService = Resolver.Get <INavigator>();

            navigationService.ForwardAsync("/LoginPage");
        }
Beispiel #4
0
        private SmartResolver CreateResolver(IComponentProvider provider)
        {
            var config = new ResolverConfig()
                         .UseAutoBinding()
                         .UseArrayBinding()
                         .UseAssignableBinding()
                         .UsePropertyInjector()
                         .UsePageContextScope();

            config.UseXamarinFormsComponents(adapter =>
            {
                adapter.AddDialogs();
                adapter.AddPopupNavigator();
                adapter.AddJsonSerializer();
                adapter.AddSettings();
            });

            config.BindSingleton <INavigator>(_ => navigator);

            config.BindSingleton <ApplicationState>();

            config.BindSingleton <IMapper>(new Mapper(new MapperConfiguration(c =>
            {
                c.AddProfile <MappingProfile>();
            })));

            config.BindSingleton <Configuration>();
            config.BindSingleton <Session>();

            config.BindSingleton(new DataServiceOptions
            {
                Path = Path.Combine(FileSystem.AppDataDirectory, "Mobile.db")
            });
            config.BindSingleton <DataService>();
            config.BindSingleton <NetworkService>();

            config.BindSingleton <NetworkOperator>();

            config.BindSingleton <SampleUsecase>();

            provider.RegisterComponents(config);

            return(config.ToResolver());
        }
Beispiel #5
0
        private static SmartResolver CreateResolver()
        {
            var config = new ResolverConfig()
                         .UseAutoBinding()
                         .UseArrayBinding()
                         .UseAssignableBinding()
                         .UsePropertyInjector();

            config.UseXamarinFormsComponents(adapter =>
            {
                adapter.AddDialogs();
            });

            config.BindSingleton(new DataServiceOptions
            {
                Path = Path.Combine(FileSystem.AppDataDirectory, "Mobile.db")
            });
            config.BindSingleton <DataService>();

            return(config.ToResolver());
        }
Beispiel #6
0
        private SmartResolver CreateResolver()
        {
            var config = new ResolverConfig()
                         .UseAutoBinding()
                         .UseArrayBinding()
                         .UseAssignableBinding()
                         .UsePropertyInjector()
                         .UsePageContextScope();

            config.UseXamarinFormsComponents(adapter =>
            {
                adapter.AddDialogs();
                adapter.AddPopupNavigator();
            });

            config.BindSingleton <INavigator>(_ => navigator);

            config.BindSingleton <ApplicationState>();

            config.BindSingleton <DataService>();

            return(config.ToResolver());
        }