private void FinalizeContainer(IWindsorContainer container) { _logger.Debug("Finalizing container"); container.Kernel.GetFacilities() .OfType <ChainOfResponsibilityFacility>() .SingleOrDefault() ?.FinalizeChains(); // Make this dependency available to generated artifacts GeneratedArtifactStaticDependencies.Resolvers.Set(() => container.Resolve <IResourceModelProvider>()); GeneratedArtifactStaticDependencies.Resolvers.Set(() => container.Resolve <IAuthorizationContextProvider>()); ClaimsPrincipal.ClaimsPrincipalSelector = () => EdFiClaimsPrincipalSelector.GetClaimsPrincipal(container.Resolve <IClaimsIdentityProvider>()); // Provide cache using a closure rather than repeated invocations to the container IPersonUniqueIdToUsiCache personUniqueIdToUsiCache = null; PersonUniqueIdToUsiCache.GetCache = () => personUniqueIdToUsiCache ?? (personUniqueIdToUsiCache = container.Resolve <IPersonUniqueIdToUsiCache>()); // Provide cache using a closure rather than repeated invocations to the container IDescriptorsCache cache = null; DescriptorsCache.GetCache = () => cache ?? (cache = container.Resolve <IDescriptorsCache>()); ResourceModelHelper.ResourceModel = new Lazy <ResourceModel>(() => container.Resolve <IResourceModelProvider>().GetResourceModel()); }
protected virtual void RegisterIDescriptorCache(IWindsorContainer container) { var absoluteExpirationPeriod = TimeSpan.FromMinutes(30); var cacheProvider = new ExpiringConcurrentDictionaryCacheProvider(absoluteExpirationPeriod); container.Register( Component.For <IDescriptorsCache>() .ImplementedBy <DescriptorsCache>() .DependsOn(Dependency.OnValue <ICacheProvider>(cacheProvider))); IDescriptorsCache cache = null; // Provide cache using a closure rather than repeated invocations to the container DescriptorsCache.GetCache = () => cache ?? (cache = container.Resolve <IDescriptorsCache>()); }
public HqlBuilder( ISessionFactory sessionFactory, IDescriptorsCache descriptorsCache, IPersonUniqueIdToUsiCache personUniqueIdToUsiCache, IResourceJoinPathExpressionProcessor resourceJoinPathExpressionProcessor, IParameterListSetter parameterListSetter) { _sessionFactory = Preconditions.ThrowIfNull(sessionFactory, nameof(sessionFactory)); _descriptorsCache = Preconditions.ThrowIfNull(descriptorsCache, nameof(descriptorsCache)); _personUniqueIdToUsiCache = Preconditions.ThrowIfNull(personUniqueIdToUsiCache, nameof(personUniqueIdToUsiCache)); _resourceJoinPathExpressionProcessor = Preconditions.ThrowIfNull( resourceJoinPathExpressionProcessor, nameof(resourceJoinPathExpressionProcessor)); _parameterListSetter = Preconditions.ThrowIfNull(parameterListSetter, nameof(parameterListSetter)); }
public PagedAggregateIdsCriteriaProvider( ISessionFactory sessionFactory, IDescriptorsCache descriptorsCache, IDefaultPageSizeLimitProvider defaultPageSizeLimitProvider) : base(sessionFactory, descriptorsCache) { _identifierColumnNames = new Lazy <string[]>( () => { var persister = (AbstractEntityPersister)SessionFactory.GetClassMetadata(typeof(TEntity)); if (persister.IdentifierColumnNames != null && persister.IdentifierColumnNames.Length > 0) { return(persister.IdentifierColumnNames); } return(new[] { "Id" }); }); _defaultPageLimitSize = defaultPageSizeLimitProvider.GetDefaultPageSizeLimit(); }
protected override void Arrange() { RegisterDependencies(); IDescriptorsCache cache = null; DescriptorsCache.GetCache = () => cache ??= _container.Resolve <IDescriptorsCache>(); IPersonUniqueIdToUsiCache personUniqueIdToUsiCache = null; PersonUniqueIdToUsiCache.GetCache = () => personUniqueIdToUsiCache ??= _container.Resolve <IPersonUniqueIdToUsiCache>(); var assembly = typeof(Program).GetTypeInfo().Assembly; XmlConfigurator.Configure(LogManager.GetRepository(assembly)); ClaimsPrincipal.ClaimsPrincipalSelector = () => EdFiClaimsPrincipalSelector.GetClaimsPrincipal(_container.Resolve <IClaimsIdentityProvider>()); _studentRepo = _container.Resolve <IUpsertEntity <Student> >(); _programRepo = _container.Resolve <IUpsertEntity <Program> >(); _studentProgramAssociationRepo = _container.Resolve <IUpsertEntity <StudentProgramAssociation> >(); _studentTitleIPartAProgramAssociationRepo = _container.Resolve <IUpsertEntity <StudentTitleIPartAProgramAssociation> >(); _upsertService = _container.Resolve <IUpsertEntity <ServiceDescriptor> >(); InitializeEducationOrganizationIdsForTest(); _studentUniqueId = Guid.NewGuid() .ToString("N"); _serviceDescriptor = GetTestServiceDescriptor(); _program1 = GetProgram1(); _program2 = GetProgram2(); _student = GetStudent(); InitializeTestData(); }
public TotalCountCriteriaProvider(ISessionFactory sessionFactory, IDescriptorsCache descriptorsCache) : base(sessionFactory, descriptorsCache) { }
public PagedAggregateIdsCriteriaProvider(ISessionFactory sessionFactory, IDescriptorsCache descriptorsCache) : base(sessionFactory, descriptorsCache) { }
protected AggregateRootCriteriaProviderBase(ISessionFactory sessionFactory, IDescriptorsCache descriptorsCache) : base(sessionFactory) { _descriptorsCache = Preconditions.ThrowIfNull(descriptorsCache, nameof(descriptorsCache)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddLog4Net(); Container = app.ApplicationServices.GetAutofacRoot(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseStaticFiles(); app.UseCors(CorsPolicyName); if (ApiSettings.GetApiMode() == ApiMode.InstanceYearSpecific) { app.UseInstanceYearSpecific(); } app.UseEdFiApiAuthentication(); app.UseAuthorization(); // Serves Open API Metadata json files when enabled. if (ApiSettings.IsFeatureEnabled(ApiFeature.OpenApiMetadata.GetConfigKeyName())) { app.UseOpenApiMetadata(); } // required to get the base controller working app.UseEndpoints( endpoints => { endpoints.MapControllers(); }); SetStaticResolvers(); RunExternalTasks(); void RunExternalTasks() { foreach (IExternalTask externalTask in Container.Resolve <IEnumerable <IExternalTask> >()) { _logger.Debug($"Running external task {externalTask.GetType().Name}"); externalTask.Execute(); } } void SetStaticResolvers() { // Make this dependency available to generated artifacts GeneratedArtifactStaticDependencies.Resolvers.Set(() => Container.Resolve <IResourceModelProvider>()); GeneratedArtifactStaticDependencies.Resolvers.Set(() => Container.Resolve <IAuthorizationContextProvider>()); // netcore has removed the claims principal from the thread, to be on the controller. // as a workaround for our current application we can resolve the IHttpContextAccessor. // c.f. https://docs.microsoft.com/en-us/aspnet/core/migration/claimsprincipal-current?view=aspnetcore-3.1 ClaimsPrincipal.ClaimsPrincipalSelector = () => Container.Resolve <IHttpContextAccessor>() .HttpContext?.User; // Provide cache using a closure rather than repeated invocations to the container IPersonUniqueIdToUsiCache personUniqueIdToUsiCache = null; PersonUniqueIdToUsiCache.GetCache = () => personUniqueIdToUsiCache ??= Container.Resolve <IPersonUniqueIdToUsiCache>(); // Provide cache using a closure rather than repeated invocations to the container IDescriptorsCache cache = null; DescriptorsCache.GetCache = () => cache ??= Container.Resolve <IDescriptorsCache>(); if (ApiSettings.GetApiMode() == ApiMode.InstanceYearSpecific) { // Provide SecurityRepository cache using a closure rather than repeated invocations to the container IInstanceSecurityRepositoryCache instanceSecurityRepositoryCache = null; InstanceSecurityRepositoryCache.GetCache = () => instanceSecurityRepositoryCache ??= Container.Resolve <IInstanceSecurityRepositoryCache>(); } ResourceModelHelper.ResourceModel = new Lazy <ResourceModel>( () => Container.Resolve <IResourceModelProvider>() .GetResourceModel()); EntityExtensionsFactory.Instance = Container.Resolve <IEntityExtensionsFactory>(); DbConfiguration.SetConfiguration(new DatabaseEngineDbConfiguration(Container.Resolve <DatabaseEngine>())); // Set NHibernate to use Autofac to resolve its dependencies NHibernate.Cfg.Environment.ObjectsFactory = new NHibernateAutofacObjectsFactory(Container); } }