Exemplo n.º 1
0
        public static void AddFatSharedComponents(this IServiceCollection services, FatSharedComponentsConfiguration configuration)
        {
            services.AddFavouritesBasket(configuration.BasketRedisConnectionString, configuration.BasketSlidingExpiryDays);

            services.AddTransient <SFA.DAS.NLog.Logger.ILog, SFA.DAS.NLog.Logger.NLogLogger>(x => new NLogLogger());

            services.AddMediatR(typeof(ApprenticeshipSearchQuery));
            services.AddTransient <ICssViewModel, DefaultCssViewModel>();
            services.AddTransient <IValidation, Validation>();
            services.AddHttpContextAccessor();
            services.AddTransient <ICookieManager, CookieManager>();

            services.AddSingleton <IPostcodeIOConfigurationSettings, FatSharedComponentsConfiguration>(s => configuration);
            services.AddSingleton <IApprenticehipFavouritesBasketStoreConfig, FatSharedComponentsConfiguration>(s => configuration);
            services.AddSingleton <ICacheSettings, FatSharedComponentsConfiguration>(s => configuration);

            //Application DI
            AddApplicationServices(services);

            //Infrastructure DI
            AddInfrastructureServices(services);

            //Orchestrator DI
            AddOrchesratorServices(services);

            AddApiSearchServices(services, configuration);

            services.AddTransient <IApprenticeshipItemViewModelMapper, ApprenticeshipItemViewModelMapper>();
            services.AddTransient <IFatSearchResultsViewModelMapper, FatSearchResultsViewModelMapper>();
            services.AddTransient <IFrameworkDetailsViewModelMapper, FrameworkDetailsViewModelMapper>();
            services.AddTransient <IStandardDetailsViewModelMapper, StandardsDetailsViewModelMapper>();
            services.AddTransient <IAssessmentOrganisationViewModelMapper, AssessmentOrganisationViewModelMapper>();
            services.AddTransient <ITrainingProviderSearchResultsItemViewModelMapper, TrainingProviderSearchResultsItemViewModelMapper>();
            services.AddTransient <ISearchResultsViewModelMapper, SearchResultsViewModelMapper>();
            services.AddTransient <IProviderSearchResultsMapper, ProviderSearchResultsMapper>();
            services.AddTransient <ISearchResultsViewModelMapper, SearchResultsViewModelMapper>();
            services.AddTransient <IFeedbackViewModelMapper, FeedbackViewModelMapper>();
            services.AddTransient <ITrainingProviderDetailsViewModelMapper, TrainingProviderDetailsViewModelMapper>();
            services.AddTransient <ITrainingProviderClosestLocationsViewModelMapper, TrainingProviderClosestLocationsViewModelMapper>();
            services.AddTransient <IBasketViewModelMapper, BasketViewModelMapper>();
            services.AddTransient <IApprenticeshipBasketItemViewModelMapper, ApprenticeshipBasketItemViewModelMapper>();


            services.AddTransient <IFatSearchFilterViewModelMapper, FatSearchFilterViewModelMapper>();
            services.AddTransient <ITrainingProviderSearchFilterViewModelMapper, TrainingProviderSearchFilterViewModelMapper>();
        }
        public void Setup()
        {
            var mockHostingEnvironment = new Mock <IHostingEnvironment>();

            mockHostingEnvironment.Setup(m => m.EnvironmentName).Returns("Development");

            _FatConfiguration = new FatSharedComponentsConfiguration()
            {
                FatApiBaseUrl = _fatApiUrl
            };

            _serviceCollection = new ServiceCollection();

            _serviceCollection.AddTransient <IHostingEnvironment>(x => mockHostingEnvironment.Object);

            _serviceCollection.AddFatSharedComponents(_FatConfiguration);

            _serviceProvider = _serviceCollection.BuildServiceProvider();
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => false;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            var fatConfig = new FatSharedComponentsConfiguration();

            Configuration.Bind("fatSharedComponents", fatConfig);
            services.AddSingleton <IFatConfigurationSettings>(fs => fatConfig);


            services.AddFatSharedComponents(fatConfig);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddFatSharedComponentsCaching("localhost");

            services.AddSingleton <ILayoutService, LayoutService>();
            services.AddTransient <ICssViewModel, CssSwitcherViewModel>();
        }