Skip to content

General Adaptation Interfaces

Gary edited this page Aug 27, 2014 · 1 revision

Table of Contents

The namespace Sce.Atf.Adaptation contains several general purpose, simple interfaces for adaptation. These interfaces are implemented by classes that want to have adapters or be adapters.

IAdaptable Interface

IAdaptable is implemented by every class that wants to be adaptable, that is, have adapters to extend its reach. Its method comes right to the point:

object GetAdapter(Type type);

This method returns the adapter for the given type. Note that the object returned is of the type specified, so by definition, it provides the desired interface for its type. Only one adapter is returned. The IDecoratable interface can be used to get a collection of adapters. Also, the Adapters.AsAll() method returns all adapters for a type. For information on this class, see Adapters Class.

IDecoratable Interface

This interface's job is to get all decorators for a type:

IEnumerable<object> GetDecorators(Type type);

In this case, decorator means adapter, so this method returns all adapters of the given type. IDecoratable complements IAdaptable, whose GetAdapter() returns a single adapter.

IAdapter Interface

IAdapter is implemented by adapters, which adapt an adaptee. IAdapter's declaration indicates it implements two other interfaces:

public interface IAdapter : IAdaptable, IDecoratable

That this interface also implements IAdaptable underscores the fact that an adapter is also an adaptee. Its one property, Adaptee, gets and sets the adaptee for the adapter.

The Adapter class implements IAdapter.

IAdapterCreator Interface

IAdapterCreator works for adapter creators and is used to build adapter factories with its methods:

  • bool CanAdapt(object adaptee, Type type): can an adapter of the desired type be created for this potential adaptee?
  • object GetAdapter(object adaptee, Type type): get an adapter of the given type for the adaptee or null if none is available.
The AdapterCreator class implements IAdapterCreator. AdapterCreator can be used to make property editors show the attributes listed in property descriptor definitions. For more information, see Metadata Driven Property Editing.

The class Sce.Atf.Dom.TypeAdapterCreator<T> implements IAdapterCreator for DomNodes.

IAdapterCreator is also used in making lists of DOM adapters for each DomNodeType. For this discussion, see Adapting to All Available Interfaces.

Topics in this section

Clone this wiki locally