lundi 25 juillet 2016

Is there an handy way to figure out whether an Object implements

I'm trying to figure out if there is any builtin routines or classes in the .NET framework that could provide a convenient way to test whether a collection implements among the following interfaces and hence hook to the relevant events, if any:

  • IEnumerable
  • IList
  • ICollection
  • IBindingList
  • IEnumerable <T>
  • IList <T>
  • ICollection <T>
  • IRaiseItemChangedEvents
  • INotifyCollectionChanged

Mostly for data-binding purposes...

I can go with a lot of reflections (e.g. IsAssignableFrom) but since it seems to be a pretty common scenario, I was wondering if there was anything already done in that regard.





Aucun commentaire:

Enregistrer un commentaire