You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, it looks like lamar does not support FromKeyedServicesAttribute which is available in .net8:
public class TestClient
{
public TestClient(
[FromKeyedServices("c1")] IMyClient myClient1,
[FromKeyedServices("c2")] IMyClient myClient2)
{
var res = myClient1.GetValue() == myClient2.GetValue();
}
}
// Container initialization code
var container = new Lamar.Container(x =>
{
x.AddKeyedSingleton<IMyClient>("c1", (p, _) => new MyClient(1));
x.AddKeyedSingleton<IMyClient>("c2", (p, _) => new MyClient(2));
x.AddTransient<TestClient>();
});
var s = container.GetService<TestClient>();
container.GetService<TestClient>() ignores FromKeyedServices attribute and injects the same instance of the dependency instead of the keyed one.
The text was updated successfully, but these errors were encountered:
@vadimi-ep Just reminding you that Lamar predates that Microsoft introduced attribute by quite a few years. This is an "I take pull requests" issue (and won't be that bad if you care).
Lamar has its own attribute for naming if that's all you need. Or use Lamar's own built in registration DSL for this that Lamar has supported for years before MS did the keyed service thing
Hello, it looks like lamar does not support
FromKeyedServicesAttribute
which is available in .net8:container.GetService<TestClient>()
ignoresFromKeyedServices
attribute and injects the same instance of the dependency instead of the keyed one.The text was updated successfully, but these errors were encountered: