I'm trying to support mapping to/from any kind of collection that implements ICollection via reflection, because ICollection requires implementation of the Add method.
This works fine for most common collection types, but fails for edge cases like LinkedList where the Add method is hidden and can only be called by casting the LinkedList to ICollection.
However it's not possible to convert to ICollection<> because it is not covariant.
The other option I was considering was searching for both implicit and explicit implementations of Add, but I don't see any information on how to do this when the interface is generic?
What would be the correct approach to take?
Aucun commentaire:
Enregistrer un commentaire