This sample ADS application demonstrates how to do dependency injection with the different ADS platform extensibility points.
Note: Dependency Injection for Event Handlers is the same as Agents, so the examples are omitted here.
Dependency Injection is a specific implementation of Dependency Inversion, one of the five S.O.L.I.D. object-oriented principles.
The internet is full of excellent documentation on the topic, but here are a few specific links:
- Dependency inversion (Microsoft)
- Dependency injection (Wikipedia)
- Dependency Injection Demystified (James Shore)
Relativity's Kepler framework supports Dependency Injection with Castle Windsor. Support is fully documented in the Relativity Developer Documentation.
See SampleApplication.Service.MyService
for a sample implementation.
Because the Custom Page sample is an ASP.NET MVC project, Castle Windsor Dependency Injection can be wired into the MVC application itself. This can be used at the unit testing level, to inject mocked classes. This can also be used at the test harness level.
See SampleApplication.CustomPage.Controllers.HomeController.cs
and the SampleApplication.CustomPage.IoC
folder for more information.
Agent and EventHAndler extensibility points don't have built-in support for Dependency Injection, but it is still possible. Two variations of a technique for implementing Dependency Injection are shown in SampleApplication.Agent.MyAgent
. The technique leverages the Lazy<T> class to delay DI Container resolution.
The code here compiles and can be tested in Visual Studio 2022. It references packages available on nuget.org.
The Agent and Service assemblies need to be uploaded to Relativity as Resource Files, and the CustomPage needs to be published, zipped, and uplaoded to Relativity as a Custom Page.