Search code examples
c#dependency-injectionsteeltoe

Msoft.Practices.Unity injection of a library that uses services pattern


I have a legacy full framework (4.7) MVC application. This application uses unity for DI.

We need to make use of the Steeltoe.CloudFoundry.Connector.Redis nuget package. This package however is expecting / used by startup.cs which I don't have.

public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddRedisConnectionMultiplexer(Configuration);
    .PersistKeysToRedis();
    
    services.AddDistributedRedisCache(Configuration);
}

What I am trying to figure out is how to use this with Unity so I can have the Steeltoe Redis connection object available for DI.

  1. Since the steeltoe projects is OSS I could just grab the source and implement directly but then I have to maintain it.

  2. (Speculation) I could have Unity generate specific classes in the nuget package...

     using Steeltoe.CloudFoundry.Connector.Redis;
     ....
     container.Resolve(RedisCacheServiceCollectionExtensions)
    
  3. Any other ideas?


Solution

  • You could do the initial implementation under Steeltoe, submit a pull request and let the community maintain it from there.

    Steeltoe's lack of support for any given DI framework isn't intentional, but rather due to a lack of pre-existing demand. We'd be happy to help you through the process of getting the code included if you're interested.