#1: Adapt based on class
- Contents
- Proposed by
- Dan Fairs
- Proposal type
- New functionality
- Assigned to release
- State
- completed
Definitions
Motivation
Currently, you need to have an interface implemented by an object which is to be adapted for adaptation to work. It should be possible to register an adapter for a class, like this:
registry.Register(typeof(Object), typeof(IProvidesInterface), typeof(Adapter));
This example would register an adapter type Adapter as an adapter for objects of class Object to interface IProvidesInterface.
Assumptions
In the example above, we register an adapter for type Object. This will adapt only instances of Objects. Allowing this registration to apply for all other object subclasses (ie. all objects) is out of scope of this proposal.
Proposal
- Allow registration of object types as well as interface types as adaptees
- Extend lookup logic to consider object registrations as well as interface registrations