Esempio n. 1
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>();
        }