Skip to content

Auto-Resource, Repository, and Service Discovery #241

Closed
@jaredcnance

Description

@jaredcnance

We should be able to reflect on the assembly and auto discover all implementations of IIdentifiable<,>, IResourceService<,>, IEntityRepository<,> adding them to the ContextGraph. A possible API might look like:

public void ConfigureServices(IServiceCollection services)
{
    services.AddJsonApi(options => 
        options.BuildContextGraph((builder) => 
            builder.AddAssembly(/*...*/);
        );
    );
}

We may also expose the following for finer control:

builder.AddAssemblyResources(/* ... */); // should also register ResourceDefinitions
builder.AddAssemblyServices(/* ... */);
builder.AddAssemblyRepositories(/* ... */);

This work may include improved handling for multiple database contexts. See #269. In order to automatically handle multiple contexts, we need a way to specify that FooRepository depends on BarDbContextResolver at startup. Currently, I don't think Microsoft's DI library provides anything with that level of registration. We could consider providing a separate package that depends on Autofac (for example) where we explicitly construct the dependency graph.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions