Share via


Command Adapters

The Command adapters transform a logical command and its parameters into a physical command. The following code shows an example of the Command adapter interface:

public interface IPhysicalCommandAdapter
{
void CommandAdapterInitialization(string initializationString, string[] targets);
object[] Command(object[] parameters, object view);
string Name { get;}
Type[] Targets { get;}
Type[] OutputParameters { get;}
string Description { get;}
}

The adapter is initialized when bound to a physical view with targets, and receives the command from Command method. The interface includes the following objects:

  • CommandAdapterInitialization: This method is invoked when creating the adapter, and receives an initialization string and an array of target paths.
  • Command: This method receives the view and an array of parameter’s object as input, and sends the actual command. This method returns an array of return object. However, currently this array is ignored and null is returned.
  • Name: A common name allowing adapter-identification at design time, which irrelevant at runtime.
  • Targets: A collection of Type objects that describe the expected types of the Target objects.
  • OutputParameters: The type of eventual return parameters. However, currently this array is ignored and null is returned.
  • Description: A string describing the usage of the adapter to be displayed by design tools. It’s irrelevant at runtime.