lundi 24 août 2020

How to Compose two objects at runtime in C# only if the first object implements interfaces required by the second?

Say I have two classes. I want to compose class A into class B.

However, for this to be valid, class B must implement a specific set of interfaces required by class A.

How could I associate class A with the list of interfaces it requires class B to implement?

I want to do this so that at run time, some type of controller can decide whether or not to add one object to the other. It will only add a to b if b implements all of the interfaces required by a.

I hope this makes sense! Thanks!

Aucun commentaire:

Enregistrer un commentaire