Ejemplo n.º 1
0
        public MediatorRequestValidators()
        {
            var services = new ServiceCollection();

            SharedKernelRegistrations.RegisterServices(services);
            services.AddMediatR(typeof(MyRequest).Assembly);
            services.AddTransient <IValidator <MyRequest>, MyRequestValidator>();
            var container = services.BuildServiceProvider();

            mediator = container.GetService <IMediator>();
        }
Ejemplo n.º 2
0
        public static void Register(
            [NotNull] IServiceCollection services,
            [NotNull] IConfiguration configuration,
            [NotNull] IHostingEnvironment hostingEnvironment)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (hostingEnvironment == null)
            {
                throw new ArgumentNullException(nameof(hostingEnvironment));
            }

            var photoStoreRoot = GetPhotoStoreRoot(configuration, hostingEnvironment);
            var photoStoreType = GetPhotoStoreType(configuration);

            SharedKernelRegistrations.RegisterServices(services);
            ApplicationRegistration.RegisterServices(services);
            InterfaceAdaptersRegistration.RegisterServices(services);

            PhotoStorageRegistration.RegisterServices(services, photoStoreRoot, photoStoreType);
            ApplicationInsightsRegistration.RegisterServices(services);
            ImageSharpRegistrations.RegisterServices(services);
            SmtpEmailRegistrations.RegisterServices(services);
            DataAccessServices.RegisterServices(services);

            services.AddSingleton <IActionContextAccessor, ActionContextAccessor>();
            services.AddSingleton <IAbsoluteUrlGenerator, MvcAbsoluteUrlGenerator>();
            services.AddSingleton <IRelativeUrlGenerator, MvcRelativeUrlGenerator>();
            services.AddSingleton <ILogbookDetailsUrlGenerator, MvcLogbookDetailsUrlGenerator>();
            services.AddSingleton <IAvatarPathProvider, AvatarPathProvider>();
            services.AddTransient <ITextFormattingHelper, TextFormattingHelper>();
            services.AddSingleton(new TokenConfiguration(GetTokenSecurityKey(configuration)));
            services.AddTransient <ITokenGenerator, TokenGenerator>();
        }