public void BuildResourceGraph <TContext>(Action <IResourceGraphBuilder> builder) where TContext : DbContext
        {
            BuildResourceGraph(builder);

            ResourceGraphBuilder.AddDbContext <TContext>();

            ResourceGraph = ResourceGraphBuilder.Build();
        }
        public void BuildResourceGraph(Action <IResourceGraphBuilder> builder)
        {
            if (builder == null)
            {
                return;
            }

            builder(ResourceGraphBuilder);

            ResourceGraph = ResourceGraphBuilder.Build();
        }
Exemple #3
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);
        }
        /// <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);
        }