Share via


Field Adapters

You can use the Field adapters to customize the field binding process. Ensure that all Field adapters must implement a specific interface:

public interface IPhysicalFieldAdapter
{
  void FieldAdapterInitialization(string initializationString);
  void FieldBind(ref object[] inputs, object[] outputs,object View, Direction dir);

  string Name { get;}
  Type[] InputParameters { get;}
  Type[] OutputParameters { get;}
  TypeConverter MceTypeConverter { get;set;}
  string Description { get;}
}

Ensure that you implement all members of the interface. However, you can use only FieldAdapterInitialization and FieldBind methods for an inline adapter. You can ignore the other methods if you intend to write inline adapters. The interface includes the following objects:

  • FieldAdapterInitialization: Invoked when the adapter is bound to a physical view, following the view creation. The initializationString provided is specified in the mapping file and allows to parametrize the adapter behavior.
  • FieldBind: This is the core method of the container and accepts two arrays of input and output objects of the types InputParameters and OutputParameters collections respectively, the physical view object, and a direction. The method moves the data from the input to the view, and from the view to the output. The output array usually resolves to the binding path of a target property onto the view, unless specified otherwise by the PhysicalProvider. The input array is the array of input object in the order it was bound.
  • Name: A common name allowing adapter-identification at design time, which irrelevant at runtime.
  • InputParameters: A collection of Type objects describing the expected types of the input objects. It is used by the PhysicalProvider to attempt a typeconversion before moving the logical values to the adapter. If no custom TypeConverter is provided, the default McetypeConverter is used.
  • OutputParameter: A collection of Type objects that describe the expected types of the output objects. It is used by the PhysicalProvider to attempt a typeconversion before moving the adapter values to the Physical view. If no custom TypeConverter is provided, the default McetypeConverter will be used.
  • MceTypeConverter: Allows the adapter to specify a custom typeConverter to be used.
  • Description: A string describing the usage of the adapter to be displayed by design tools. It’s irrelevant at runtime.