コード例 #1
0
        /// <summary>
        /// Configures and builds the resource graph with resources from the provided sources and adds it to the DI container.
        /// </summary>
        public void AddResourceGraph(Type dbContextType, Action <ResourceGraphBuilder> configureResourceGraph)
        {
            _serviceDiscoveryFacade.DiscoverResources();

            if (dbContextType != null)
            {
                AddResourcesFromDbContext((DbContext)_intermediateProvider.GetService(dbContextType), _resourceGraphBuilder);
            }

            configureResourceGraph?.Invoke(_resourceGraphBuilder);

            var resourceGraph = _resourceGraphBuilder.Build();

            _services.AddSingleton(resourceGraph);
        }
コード例 #2
0
        /// <summary>
        /// Configures and builds the resource graph with resources from the provided sources and adds it to the DI container.
        /// </summary>
        public void AddResourceGraph(ICollection <Type> dbContextTypes, Action <ResourceGraphBuilder> configureResourceGraph)
        {
            _serviceDiscoveryFacade.DiscoverResources();

            foreach (var dbContextType in dbContextTypes)
            {
                var dbContext = (DbContext)_intermediateProvider.GetRequiredService(dbContextType);
                AddResourcesFromDbContext(dbContext, _resourceGraphBuilder);
            }

            configureResourceGraph?.Invoke(_resourceGraphBuilder);

            var resourceGraph = _resourceGraphBuilder.Build();

            _services.AddSingleton(resourceGraph);
        }