Skip to content

Dependency Injection migration #137

Description

@JeremyCaney

The sample application (and most implementors) currently wire up services manually via a custom "activator" that constructs each dependency via a switch, rather than using .NET's standard, built-in dependency-injection container. This replaces that with idiomatic DI registration.

Tasks

  • Add an AddOnTopic() registration helper for the core mapping/lookup services (ServiceCollectionExtensions, OnTopic.AspNetCore.Mvc)
  • Add an AddTopicNavigation<TViewModel>() helper for the hierarchical navigation service (ServiceCollectionExtensions)
  • Add an AddSqlTopicRepository() helper for the SQL repository (OnTopic.Data.Sql)
  • Add an AddTopicCaching() helper for the caching repository (OnTopic.Data.Caching)
    • Must register ITopicRepository as a singleton; anything less silently creates a fresh, empty cache per request
  • Delete the activator from the sample host; wire it up via the new registration helpers (SampleActivator, Program, OnTopic.AspNetCore.Mvc.Host)
  • Delete the activator from the integration test host; wire it up the same way (SampleActivator, OnTopic.AspNetCore.Mvc.IntegrationTests.Host)
  • Apply the same pattern to the OnTopic Editor's SampleActivator
  • Create unit tests to validate the above logic

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions