KGy SOFT

ICommandBinding Interface

KGy SOFT Core Libraries Help
Represents a binding for a command.
See the Remarks section for details.

Namespace:  KGySoft.ComponentModel
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.0.0-rc.1
Syntax

public interface ICommandBinding : IDisposable

The ICommandBinding type exposes the following members.

Properties

  NameDescription
Public propertyIsDisposed
Gets whether this ICommandBinding instance is disposed.
Public propertySources
Gets a copy of the sources of this ICommandBinding along with the bound event names.
Public propertyState
Gets the managed set of states of this ICommandBinding instance. Whenever a new source is added or an entry of the returned ICommandState is changed, and at least one ICommandStateUpdater is added to this ICommandBinding, then the entries are applied for all of the sources of the binding.
See the Remarks section if the ICommandState interface for details.
Public propertyStateUpdaters
Gets a copy of the state updaters of this ICommandBinding.
Public propertyTargets
Gets a copy of the targets of this ICommandBinding.
Top
Methods

  NameDescription
Public methodAddSource
Adds a source to this ICommandBinding instance. For static events pass a Type as source. If state updaters were added to the binding by the AddStateUpdater method, then the State entries will be applied to the new source. At least one source has to be added to the binding to be able to invoke the underlying ICommand.
Public methodAddStateUpdater
Adds a state updater to the binding. If at least one updater is added, then changing the entries of the State property will be applied on all added sources.
See the Remarks section of the ICommandStateUpdater interface for details.
Public methodAddTarget(FuncObject)
Adds a target getter function to this ICommandBinding instance. Whenever the underlying ICommand executes it will evaluate the specified getter delegate.
Public methodAddTarget(Object)
Adds the target to this ICommandBinding instance. The underlying ICommand will be invoked for each added target. If no targets are added the command will be invoked with a  target.
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from IDisposable.)
Public methodInvokeCommand
Invokes the underlying ICommand for all of the added targets using the specified source, event name and arguments.
Public methodRemoveSource
Removes the specified source from this ICommandBinding instance. The used events of the removed source will be released.
Public methodRemoveStateUpdater
Removes the specified state updater. The removed updater will not be disposed.
Public methodRemoveTarget
Removes the specified target from this ICommandBinding instance.
Top
Events

  NameDescription
Public eventExecuted
Occurs when the associated ICommand has been executed.
Public eventExecuting
Occurs when the associated ICommand is about to be executed. Command states, including the Enabled state still can be adjusted here.
Top
Remarks

Whereas an ICommand is a static logic without state, the created binding is a dynamic entity: it has a state, which can store variable elements (see ICommandState), and has sources and targets, which can be added and removed during the lifetime of the binding.

The binding should be disposed when it is not used anymore so it releases the events it used internally. If more bindings are used it is recommended to create them by a CommandBindingsCollection instance so when it is disposed it releases all of the added bindings at once.

Tip Tip
See the Remarks section of the ICommand interface for details and examples about commands.
See Also

Reference