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
 public static ResolverConfig AddAccessorFactory(this ResolverConfig config)
 {
     return(config.AddAccessorFactory(c => { }));
 }