Open petrsvihlik opened 4 years ago
Hi, I have been using the SDK over a year now and must say the fact that I can't assigned a custom type provider to a named HttpClient through the .NetCore dependency injection mechanisme represents a real problem on my side. There is the possibility to create an instance of a SharedTypeProvider class however it only works if all your content types (accross projects) have different names, unfortunately in my case I have content types that share the same name accross projects.
Could we have quick exemple of what solution 4 would look like ? In my case it is very important that I can match a content type provider to a specific named client.
Thanks
Hi @vletierce, thanks for your feedback. You probably wanted to comment on this one: https://github.com/Kentico/kontent-delivery-sdk-net/issues/240 (see problem no. 2)
Please check out the suggested approach and let us know if it's viable for you.
e.g. #271
Motivation
We receive a lot of various error reports (on StackOverflow, GitHub, support chat on intercom) that all have one common denominator: they are caused by a missing registration of the
ITypeProvider
implementation.There are more ways to register the implementation and they are described here: https://github.com/Kentico/kontent-delivery-sdk-net/wiki/Working-with-strongly-typed-models#adding-support-for-runtime-type-resolution
For simplicity (and historical reasons), the registration is not included in the README (so probably a lot of people miss it at that point). The fact is that the
ITypeProvider
is not required for the simplest scenarios such as retrieving a 1st level model without complex types. However, for anything more complex (linked items, rich text, etc.) it absolutely necessary to have it registered.Proposed solution
We have a few options:
ITypeProvider
mandatory and throw an exception if omittedYour opinion
Let us know what would be an appropriate solution for you (if you were a new user of the SDK).