Registering Services for IEnumerable Injection Service Registration Fundamentals Service registration is the process of telling the DI container how to create instances of a service, typically done at application startup. Registering Services for IEnumerable When services implement a common interface, you can register them in such a way that the DI container can provide an IEnumerable of these services. In .NET, for example: services.AddTransient<ICommonService, ServiceA>(); services.AddTransient<ICommonService, ServiceB>(); Why would you register mulitple instances of the same interface? One use-case is that it is the same service with a different configuration. Here is an example of how that would look: services.Configure<CustomOption>("Opt1", configuration.GetSection("Options1")); services.Configure<CustomOption>("Opt2", configuration.GetSection("Options2")); builder.Services.AddSingleton<ICommonService,Servic
If you're in technology, AIs are everywhere nowadays. At work, I use an AI to help me make proofs of concept, sometimes in communicating with other AIs. At home, I use Google's Bard to help with those day-to-day mental chores such as meal planning. Even at play, when indulging in some Gran Turismo there's an AI to race against . I can't do anything about the AIs I use more casually (aside from being aware of them). At work though, I have some control! When interfacing with an AI through an API, you're given the opportunity to tweak parameters or try the same query with different contexts before getting a response from your AI. And what better to help judge your user engagement with an AI than Optimizely's Feature Experimentation! Here I'll be working with OpenAI's API along with their client package from nuget in order to simplify some rather ugly setup. I'll include an HttpClient version of the call at the end of the post so you can see the details