-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decorator and ResolveAll<> interaction #141
Comments
Ok, I think I figured this out. container.RegisterDecorator<IAnimalRepository, CachedAnimalRepository>(c => c.AsServiceAlso<IDataRepository>().When(t => t.Type.IsAssignableTo(typeof(IAnimalRepository))));
container.RegisterDecorator<ICarRepository, CachedCarRepository>(c => c.AsServiceAlso<IDataRepository>().When(t => t.Type.IsAssignableTo(typeof(ICarRepository))));
container.RegisterDecorator<IPhoneRepository, CachedPhoneRepository>(c => c.AsServiceAlso<IDataRepository>().When(t => t.Type.IsAssignableTo(typeof(IPhoneRepository)))); Not sure if this is the best approach, but it is working :) |
Hi @eValker, thank you for reporting this. I see you found a workaround but I recognised this as a bug. In container.RegisterDecorator<CachedAnimalRepository>(c => c.AsServiceAlso<IDataRepository>());
container.RegisterDecorator<CachedCarRepository>(c => c.AsServiceAlso<IDataRepository>());
container.RegisterDecorator<CachedPhoneRepository>(c => c.AsServiceAlso<IDataRepository>()); or: container.RegisterDecorator<CachedAnimalRepository>(c => c.AsImplementedTypes());
container.RegisterDecorator<CachedCarRepository>(c => c.AsImplementedTypes());
container.RegisterDecorator<CachedPhoneRepository>(c => c.AsImplementedTypes()); The container will now treat your resolution request correctly. Could you please re-check your setup that it works now as expected? Thanks |
Hello,
While working on a project I found weird resolver's behaviour. I ma not sure whether I am doing something wrong or if it is just a bug in the library :)
Here is a code sample to reproduce the issue:
Expected value
Inside CollectionOfServices constructor, I'm expecting to recieve an array of 3 different data repositories (for animals, cars and phones) wrapped in cached implementations and also HouseRepositry, e.g.
Actual value
CollectionOfServices constructor recieves an array of 4 CachedPhoneRepository instances.
![image](https://private-user-images.githubusercontent.com/6340737/258805093-32fbc16f-ad61-4f5c-80b5-b58fa6a01fd0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxMzIyNzQsIm5iZiI6MTcyMDEzMTk3NCwicGF0aCI6Ii82MzQwNzM3LzI1ODgwNTA5My0zMmZiYzE2Zi1hZDYxLTRmNWMtODBiNS1iNThmYTZhMDFmZDAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MDRUMjIyNjE0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzAxZDJhYzI1NTgzN2M1OWNmYmE2OTE2OTA2YjVkZTVkNWM5OTY5YjU1Njk4MTFkYzYzYjVhNTI1MDUwNzQ4ZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Gj1rXZUJP4za8L8Zzg1sHgvgx_RMz5DtFo8Nh_z5IwA)
I am not sure how can I change the configuration to achive what I need. I little help would be appreciated :)
The text was updated successfully, but these errors were encountered: