共用方式為


ICommandHandler<T> Interface

Definition

Represents a handler for a command associated with specific CommandArgs.

generic <typename T>
 where T : CommandArgspublic interface class ICommandHandler : Microsoft::VisualStudio::Commanding::ICommandHandler, Microsoft::VisualStudio::Utilities::INamed
public interface ICommandHandler<T> : Microsoft.VisualStudio.Commanding.ICommandHandler, Microsoft.VisualStudio.Utilities.INamed where T : CommandArgs
type ICommandHandler<'T (requires 'T :> CommandArgs)> = interface
    interface ICommandHandler
    interface INamed
Public Interface ICommandHandler(Of T)
Implements ICommandHandler, INamed

Type Parameters

T
Implements

Examples

[Export(typeof(ICommandHandler))]
[Name(nameof(MyCommandHandler))]
[ContentType("text")]
[Order(Before ="OtherCommandHandler")]   
[TextViewRole(PredefinedTextViewRoles.Editable)]
internal class MyCommandHandler : ICommandHandler<MyCommandArgs>

Remarks

This is a MEF component part and should be exported as the non-generic ICommandHandler with required [Name], [ContentType] attributes and optional [Order] and [TextViewRole] attributes.

Properties

DisplayName

Gets display name of an instance used to represent it to the user, for example when blaming it for delays.

(Inherited from INamed)

Methods

ExecuteCommand(T, CommandExecutionContext)

Called to execute the command.

GetCommandState(T)

Called to determine the state of the command.

Extension Methods

ExecuteCommand<T>(ICommandHandler, T, Action, CommandExecutionContext)

Called to execute the command.

GetCommandState<T>(ICommandHandler, T, Func<CommandState>)

Called to determine the state of the command.

Applies to