It takes quite an effort to instrument/inject some of the Steeltoe features in full framework app. SteeltoeOSS has Autofac extensions for full framework to abstarct away that effort. But there are no Unity extensions availble. Sample apps in steeltoe-unity-samples git repo illustrate how to use Steeltoe features with less effort when using Unity for IoC services.
How it works? - configure and add services to Micorsoft DI container and load them into Unity container. So you can leverage Unity IoC in your apps the same way you do and can inject Steeltoe interfaces. Unity container will resolve them without any issues.
Note: Create/upgrade your app to target .Net Framework 4.6.1 or above, since we are making use of .Net Standard libraries
Get Unity.Microsoft.DependencyInjection nuget
Add services to Microsoft DI container. Refer to ApplicationConfig.cs
Use DiscoveryConfig.cs to register/fetch your app in/from Eureka server
Use ManagementConfig.cs to add cloudfoundry management endpoints and healthchecks
Register and build service provider in Application_Start() method in Global.asax.cs
// register microsoft & steeltoe services
ApplicationConfig.Register(Environment.GetEnvironmentVariable("ASPNET_ENVIRONMENT") ?? "Development");
// build service provider for unity container
ApplicationConfig.BuildServiceProvider(UnityConfig.Container);
BuildServiceProvider(UnityConfig.Container) method loads regsitrations from Microsoft container to Unity container
public static void BuildServiceProvider(IUnityContainer container)
{
// add services to unity container. piggy backing on Unity.Microsoft.DependencyInjection extensions
container.BuildServiceProvider(_services);
}
Refer to Global.asax.cs to start and stop Discovery client