Share via


Adapters

Adapters are classes that include custom code used to bind data, events or commands to a physical view. You can use adapters to reuse a custom binding logic across multiple views, instead of repeating it the multiple views. It is recommended that you build adapters when working with bindings that are shared across more than one view, and to handle unique cases at the single-view level. You can implement the three adapter types in the same class definition whenever required.

There are three kinds of adapters:

  • Field Adapters: You can use field adapters to customize the way fields are bound to physical Views. For more information, see Field Adapters.
  • Event Adapters: You can use event adapters to customize wiring and handling of physical view events, and delivering them to the MceEngine. For more information, see Event Adapters.
  • Command adapters: You can use command adapters to customize the delivery of bindings to the physical views. For more information, see Command Adapters.

Further the adapters as categorized as follows:

  • Inline adapters: Map a single logical entity (field, event or command) to a single physical entity, and are used inline via an AdapterBinding in the mapping file
  • Complex adapters: Handle multiple logical fields and multiple physical views, to provide a customized binding logic. They are defined in a separate section of the mapping file.

The MCE Engine creates adapter instances per view, with same lifetime as the physical view. Hence, you can easily implement multiple bindings, events or commands inside an adapter to generate complex behaviors.