Пример #1
0
        public static void WithEFCoreOutbox <T>(this IServiceRegistrar services,
                                                Action <EFCoreOutbox.OutboxSettings> config
                                                ) where T : DbContext
        {
            OutboxSettings settings = new OutboxSettings();

            if (config != null)
            {
                config.Invoke(settings);
            }
            services.AddSingleton <OutboxSettings>(settings);
            services.AddSingleton <IOutbox, Outbox <T> >(true);
            services.AddTransient <IOutboxSession, OutboxSession <T> >();
        }
Пример #2
0
        public void Register()
        {
            serviceRegistrar
            .AddSingleton <Subscriber>()
            .AddTransient <IMessageProcessor, MessageProcessor>();

            // etc. for all of Pat's internals
            // also call to methods in pipeline builder classes to assemble message and batch behaviour chains from the types above
        }
        private static IServiceRegistrar Register(this IServiceRegistrar serviceRegistrar, Type serviceType, Type implementationType, RegistrationScope registrationScope)
        {
            switch (registrationScope)
            {
            case RegistrationScope.Singleton:
                return(serviceRegistrar.AddSingleton(serviceType, implementationType));

            case RegistrationScope.Scoped:
                return(serviceRegistrar.AddScoped(serviceType, implementationType));

            case RegistrationScope.Transient:
                return(serviceRegistrar.AddTransient(serviceType, implementationType));

            default:
                break;
            }

            return(serviceRegistrar);
        }