Beispiel #1
0
        public DefaultServiceProviderTestsX()
        {
            serviceProvider = new DefaultServiceProvider();

            serviceProvider.Register <IRoot, Root>();
            serviceProvider.Register <IChild, Child>();
            serviceProvider.Register <IGrandChild, GrandChild>();
        }
        public void SetUp()
        {
            serviceProvider = new DefaultServiceProvider();

            serviceProvider.Register <IRoot, Root>();
            serviceProvider.Register <IChild, Child>();
            serviceProvider.Register <IGrandChild, GrandChild>();
        }
        public void SetUp()
        {
            serviceProvider = new DefaultServiceProvider();

            serviceProvider.Register<IRoot, Root>();
            serviceProvider.Register<IChild, Child>();
            serviceProvider.Register<IGrandChild, GrandChild>();
        }
        public void SetUp()
        {
            myFirst      = MockRepository.GenerateStub <IMyFirst>();
            someDelegate = () => { };

            var defaultServiceProvider = new DefaultServiceProvider();

            defaultServiceProvider.Register(x => myFirst);
            defaultServiceProvider.Register(x => someDelegate);
            defaultServiceProvider.Register <IMySecond>(x => new MySecond(x.Resolve <IMyFirst>()));

            serviceProvider = defaultServiceProvider;
        }
Beispiel #5
0
        public DefaultServiceProviderTests()
        {
            myFirst      = Substitute.For <IMyFirst>();
            someDelegate = () => { };

            var defaultServiceProvider = new DefaultServiceProvider();

            defaultServiceProvider.Register(x => myFirst);
            defaultServiceProvider.Register(x => someDelegate);
            defaultServiceProvider.Register <IMySecond>(x => new MySecond(x.Resolve <IMyFirst>()));

            serviceProvider = defaultServiceProvider;
        }
        public void SetUp()
        {
            myFirst = MockRepository.GenerateStub<IMyFirst>();
            someDelegate = () => { };

            var defaultServiceProvider = new DefaultServiceProvider();

            defaultServiceProvider.Register(x => myFirst);
            defaultServiceProvider.Register(x => someDelegate);
            defaultServiceProvider.Register<IMySecond>(x => new MySecond(x.Resolve<IMyFirst>()));

            serviceProvider = defaultServiceProvider;
        }
        public static IServiceProvider CreateServiceProvider(Action<IServiceRegister> registerServices)
        {
            Preconditions.CheckNotNull(registerServices, "registerServices");

            var serviceProvider = new DefaultServiceProvider();
            registerServices(serviceProvider);

            // we only want single instances of these shared services, so instantiate them here
            var logger = new ConsoleLogger();
            var serializer = new JsonSerializer();
            var conventions = new Conventions();

            // default service registration
            serviceProvider
                .Register<IEasyNetQLogger>(x => logger)
                .Register<ISerializer>(x => serializer)
                .Register<IConventions>(x => conventions)
                .Register<SerializeType>(x => TypeNameSerializer.Serialize)
                .Register<Func<string>>(x => CorrelationIdGenerator.GetCorrelationId)
                .Register<IClusterHostSelectionStrategy<ConnectionFactoryInfo>>(x => new DefaultClusterHostSelectionStrategy<ConnectionFactoryInfo>())
                .Register<IConsumerDispatcherFactory>(x => new ConsumerDispatcherFactory(x.Resolve<IEasyNetQLogger>()))
                .Register<IConsumerErrorStrategy>(x => new DefaultConsumerErrorStrategy(
                    x.Resolve<IConnectionFactory>(),
                    x.Resolve<ISerializer>(),
                    x.Resolve<IEasyNetQLogger>(),
                    x.Resolve<IConventions>()))
                .Register<IHandlerRunner>(x => new HandlerRunner(
                    x.Resolve<IEasyNetQLogger>(),
                    x.Resolve<IConsumerErrorStrategy>()))
                .Register<IInternalConsumerFactory>(x => new InternalConsumerFactory(
                    x.Resolve<IHandlerRunner>(),
                    x.Resolve<IEasyNetQLogger>(),
                    x.Resolve<IConventions>(),
                    x.Resolve<IConnectionConfiguration>(),
                    x.Resolve<IConsumerDispatcherFactory>()))
                .Register<IConsumerFactory>(x => new ConsumerFactory(x.Resolve<IInternalConsumerFactory>()))
                .Register<IConnectionFactory>(x => new ConnectionFactoryWrapper(
                    x.Resolve<IConnectionConfiguration>(),
                    x.Resolve<IClusterHostSelectionStrategy<ConnectionFactoryInfo>>()))
                .Register<IMessageValidationStrategy>(x => new DefaultMessageValidationStrategy(
                    x.Resolve<IEasyNetQLogger>(),
                    x.Resolve<SerializeType>()))
                .Register<IAdvancedBus>(x => new RabbitAdvancedBus(
                    x.Resolve<IConnectionFactory>(),
                    x.Resolve<SerializeType>(),
                    x.Resolve<ISerializer>(),
                    x.Resolve<IConsumerFactory>(),
                    x.Resolve<IEasyNetQLogger>(),
                    x.Resolve<Func<string>>(),
                    x.Resolve<IMessageValidationStrategy>()))
                .Register<IBus>(x => new RabbitBus(
                    x.Resolve<SerializeType>(),
                    x.Resolve<IEasyNetQLogger>(),
                    x.Resolve<IConventions>(),
                    x.Resolve<IAdvancedBus>()
                ));

            return serviceProvider;
        }
        public static IServiceProvider CreateServiceProvider(Action<IServiceRegister> registerServices)
        {
            Preconditions.CheckNotNull(registerServices, "registerServices");

            var serviceProvider = new DefaultServiceProvider();

            // gives the user a chance to register alternative service implementations.
            registerServices(serviceProvider);

            // Note: IConnectionConfiguration gets registered when RabbitHutch.CreateBus(..) is run.

            // default service registration
            serviceProvider
                .Register<IEasyNetQLogger, ConsoleLogger>()
                .Register<ISerializer, JsonSerializer>()
                .Register<IConventions, Conventions>()
                .Register<IEventBus, EventBus>()
                .Register<ITypeNameSerializer, TypeNameSerializer>()
                .Register<Func<string>>(x => CorrelationIdGenerator.GetCorrelationId)
                .Register<IClusterHostSelectionStrategy<ConnectionFactoryInfo>, DefaultClusterHostSelectionStrategy<ConnectionFactoryInfo>>()
                .Register<IConsumerDispatcherFactory, ConsumerDispatcherFactory>()
                .Register<IPublishExchangeDeclareStrategy, PublishExchangeDeclareStrategy>()
                .Register<IPublisherConfirms, PublisherConfirms>()
                .Register<IConsumerErrorStrategy, DefaultConsumerErrorStrategy>()
                .Register<IHandlerRunner, HandlerRunner>()
                .Register<IInternalConsumerFactory, InternalConsumerFactory>()
                .Register<IConsumerFactory, ConsumerFactory>()
                .Register<IConnectionFactory, ConnectionFactoryWrapper>()
                .Register<IPersistentChannelFactory, PersistentChannelFactory>()
                .Register<IClientCommandDispatcherFactory, ClientCommandDispatcherFactory>()
                .Register<IHandlerCollectionFactory, HandlerCollectionFactory>()
                .Register<IAdvancedBus, RabbitAdvancedBus>()
                .Register<IRpc, Rpc>()
                .Register<ISendReceive, SendReceive>()
                .Register<IBus, RabbitBus>();

            return serviceProvider;
        }