コード例 #1
0
ファイル: Usage.cs プロジェクト: usausa/Work-Net-Data
        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();
        }
コード例 #2
0
            public void RegisterComponents(ResolverConfig config)
            {
                config.Bind <Context>().ToConstant(activity).InSingletonScope();

                config.Bind <IApplicationDialog>().To <ApplicationDialog>().InSingletonScope();
                config.Bind <IDeviceManager>().ToConstant(activity.deviceManager).InSingletonScope();
            }
コード例 #3
0
        private void RegisterComponents(ResolverConfig config)
        {
            config.UseAutoBinding();
            config.UseNavigator();
            config.Bind <ISettingService>().To <SettingService>().InSingletonScope();
            config.Bind <IDialogService>().To <DialogService>().InSingletonScope();
            config.Bind <IPlatformService>().To <PlatformService>().InSingletonScope();
            config.Bind <INetworkClient>().To <NetworkClient>().InSingletonScope();

            config.Bind <ItemService>().ToSelf().InSingletonScope();
            config.Bind <EntryService>().ToSelf().InSingletonScope();
            config.Bind <InspectionService>().ToSelf().InSingletonScope();

            config.Bind <Session>().ToSelf().InSingletonScope();
        }
コード例 #4
0
        public static ResolverConfig AddAccessorFactory(this ResolverConfig config, Action <IAccessorFactoryConfigExpression> action)
        {
            var expression = new AccessorFactoryConfigExpression();

            action(expression);

            config.UseMissingHandler <DaoMissingHandler>();

            if (expression.Executor != null)
            {
                config.Bind <IExecutor>().ToConstant(expression.Executor).InSingletonScope();
            }
            else if (expression.ExecutorType != null)
            {
                config.Bind <IExecutor>().To(expression.ExecutorType).InSingletonScope();
            }
            else if (expression.ExecutorFactory != null)
            {
                config.Bind <IExecutor>().ToMethod(expression.ExecutorFactory).InSingletonScope();
            }

            if (expression.ConnectionManager != null)
            {
                config.Bind <IConnectionManager>().ToConstant(expression.ConnectionManager).InSingletonScope();
            }
            else if (expression.ConnectionManagerType != null)
            {
                config.Bind <IConnectionManager>().To(expression.ConnectionManagerType).InSingletonScope();
            }
            else if (expression.ConnectionManagerFactory != null)
            {
                config.Bind <IConnectionManager>().ToMethod(expression.ConnectionManagerFactory).InSingletonScope();
            }

            config.Bind <IAccessorFactoryConfig>().To <AccessorFactoryConfig>();
            config.Bind <IAccessorFactory>().To <AccessorFactory>();

            return(config);
        }
コード例 #5
0
 public void RegisterComponents(ResolverConfig config)
 {
     config.Bind <IBarcodeService>().To <MobileBarcodeService>().InSingletonScope();
     config.Bind <IFileService>().To <FileService>().InSingletonScope();
     config.Bind <ILoadingService>().To <LoadingService>().InSingletonScope();
 }
コード例 #6
0
            public void RegisterComponents(ResolverConfig config)
            {
                config.Bind <Activity>().ToConstant(activity).InSingletonScope();

                config.Bind <IApplicationDialog>().To <ApplicationDialog>().InSingletonScope();
            }
コード例 #7
0
 public void RegisterComponents(ResolverConfig config)
 {
     config.Bind <Context>().ToConstant(activity).InSingletonScope();
 }