private void AddResourcesFromDbContext(DbContext dbContext, ResourceGraphBuilder builder)
 {
     foreach (var entityType in dbContext.Model.GetEntityTypes())
     {
         builder.Add(entityType.ClrType);
     }
 }
예제 #2
0
        public void BuildResourceGraph <TContext>(Action <IResourceGraphBuilder> builder) where TContext : DbContext
        {
            BuildResourceGraph(builder);

            ResourceGraphBuilder.AddDbContext <TContext>();

            ResourceGraph = ResourceGraphBuilder.Build();
        }
        public JsonApiApplicationBuilder(IServiceCollection services, IMvcCoreBuilder mvcBuilder)
        {
            _services   = services ?? throw new ArgumentNullException(nameof(services));
            _mvcBuilder = mvcBuilder ?? throw new ArgumentNullException(nameof(mvcBuilder));

            _intermediateProvider = services.BuildServiceProvider();
            var loggerFactory = _intermediateProvider.GetRequiredService <ILoggerFactory>();

            _resourceGraphBuilder   = new ResourceGraphBuilder(_options, loggerFactory);
            _serviceDiscoveryFacade = new ServiceDiscoveryFacade(_services, _resourceGraphBuilder, _options, loggerFactory);
        }
예제 #4
0
        public void BuildResourceGraph(Action <IResourceGraphBuilder> builder)
        {
            if (builder == null)
            {
                return;
            }

            builder(ResourceGraphBuilder);

            ResourceGraph = ResourceGraphBuilder.Build();
        }
예제 #5
0
        public ServiceDiscoveryFacade(IServiceCollection services, ResourceGraphBuilder resourceGraphBuilder, ILoggerFactory loggerFactory)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _logger               = loggerFactory.CreateLogger <ServiceDiscoveryFacade>();
            _services             = services ?? throw new ArgumentNullException(nameof(services));
            _resourceGraphBuilder = resourceGraphBuilder ?? throw new ArgumentNullException(nameof(resourceGraphBuilder));
        }
        public ServiceDiscoveryFacade(IServiceCollection services, ResourceGraphBuilder resourceGraphBuilder, IJsonApiOptions options, ILoggerFactory loggerFactory)
        {
            ArgumentGuard.NotNull(services, nameof(services));
            ArgumentGuard.NotNull(resourceGraphBuilder, nameof(resourceGraphBuilder));
            ArgumentGuard.NotNull(loggerFactory, nameof(loggerFactory));
            ArgumentGuard.NotNull(options, nameof(options));

            _logger               = loggerFactory.CreateLogger <ServiceDiscoveryFacade>();
            _services             = services;
            _resourceGraphBuilder = resourceGraphBuilder;
            _options              = options;
        }