Class FlexibleCommandBinder
- Namespace
- ReactiveUI
- Assembly
- ReactiveUI.dll
Command binder for android controls.
public abstract class FlexibleCommandBinder : Object, ICreatesCommandBinding
- Inheritance
-
FlexibleCommandBinder
- Implements
- Derived
- Extension Methods
Constructors
FlexibleCommandBinder()
protected FlexibleCommandBinder()
Methods
BindCommandToObject(ICommand?, object?, IObservable<object?>)
Bind an ICommand to a UI object, in the "default" way. The meaning of this is dependent on the implementation. Implement this if you have a new type of UI control that doesn't have Command/CommandParameter like WPF or has a non-standard event name for "Invoke".
public IDisposable? BindCommandToObject(ICommand? command, object? target, IObservable<object?> commandParameter)
Parameters
command
ICommandThe command to bind.
target
objectThe target object, usually a UI control of some kind.
commandParameter
IObservable<object>An IObservable source whose latest value will be passed as the command parameter to the command. Hosts will always pass a valid IObservable, but this may be Observable.Empty.
Returns
- IDisposable
An IDisposable which will disconnect the binding when disposed.
BindCommandToObject<TEventArgs>(ICommand?, object?, IObservable<object?>, string)
Bind an ICommand to a UI object to a specific event. This event may be a standard .NET event, or it could be an event derived in another manner (i.e. in MonoTouch).
public IDisposable BindCommandToObject<TEventArgs>(ICommand? command, object? target, IObservable<object?> commandParameter, string eventName) where TEventArgs : EventArgs
Parameters
command
ICommandThe command to bind.
target
objectThe target object, usually a UI control of some kind.
commandParameter
IObservable<object>An IObservable source whose latest value will be passed as the command parameter to the command. Hosts will always pass a valid IObservable, but this may be Observable.Empty.
eventName
stringThe event to bind to.
Returns
- IDisposable
An IDisposable which will disconnect the binding when disposed.
Type Parameters
TEventArgs
The event argument type.
ForEvent(ICommand?, object?, IObservable<object?>, string, PropertyInfo)
Creates a commands binding from event and a property.
protected static IDisposable ForEvent(ICommand? command, object? target, IObservable<object?> commandParameter, string eventName, PropertyInfo enabledProperty)
Parameters
command
ICommandCommand.
target
objectTarget.
commandParameter
IObservable<object>Command parameter.
eventName
stringEvent name.
enabledProperty
PropertyInfoEnabled property name.
Returns
- IDisposable
The binding from event.
ForTargetAction(ICommand?, object?, IObservable<object?>, PropertyInfo)
Creates a commands binding from event and a property.
protected static IDisposable ForTargetAction(ICommand? command, object? target, IObservable<object?> commandParameter, PropertyInfo enabledProperty)
Parameters
command
ICommandThe command.
target
objectThe target object.
commandParameter
IObservable<object>The command parameter.
enabledProperty
PropertyInfoThe enabled property.
Returns
- IDisposable
Returns a disposable.
GetAffinityForObject(Type, bool)
Returns a positive integer when this class supports BindCommandToObject for this particular Type. If the method isn't supported at all, return a non-positive integer. When multiple implementations return a positive value, the host will use the one which returns the highest value. When in doubt, return '2' or '0'.
public int GetAffinityForObject(Type type, bool hasEventTarget)
Parameters
type
TypeThe type to query for.
hasEventTarget
boolIf true, the host intends to use a custom event target.
Returns
- int
A positive integer if BCTO is supported, zero or a negative value otherwise.
Register(Type, int, Func<ICommand?, object?, IObservable<object?>, IDisposable>)
Registers an observable factory for the specified type and property.
protected void Register(Type type, int affinity, Func<ICommand?, object?, IObservable<object?>, IDisposable> createBinding)
Parameters
type
TypeType.
affinity
intThe affinity for the type.
createBinding
Func<ICommand, object, IObservable<object>, IDisposable>Creates the binding.