Skip to content

Commit

Permalink
style: tidy up command binding comments
Browse files Browse the repository at this point in the history
  • Loading branch information
olevett committed Feb 8, 2017
1 parent 73cd42e commit 8d12b0e
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions src/ReactiveUI/CommandBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace ReactiveUI
{
/// <summary>
/// Various helpers to bind View controls and ViewModel commands together
/// </summary>
public static class CommandBinder
{
static ICommandBinderImplementation binderImplementation;
Expand All @@ -30,7 +33,7 @@ static CommandBinder()
/// <param name="view">The View</param>
/// <param name="viewModel">The View model</param>
/// <param name="controlName">The name of the control on the view</param>
/// <param name="propertyName">The ViewModel command to Bind.</param>
/// <param name="propertyName">The ViewModel command to bind.</param>
/// <param name="withParameter">The ViewModel property to pass as the
/// param of the ICommand</param>
/// <param name="toEvent">If specified, bind to the specific event
Expand All @@ -57,6 +60,7 @@ static CommandBinder()
/// the binding</returns>
/// <param name="view">The View</param>
/// <param name="viewModel">The View model</param>
/// <param name="propertyName">The ViewModel command to bind</param>
/// <param name="controlName">The name of the control on the view</param>
/// <param name="toEvent">If specified, bind to the specific event
/// instead of the default.</param>
Expand All @@ -81,6 +85,7 @@ static CommandBinder()
/// the binding</returns>
/// <param name="view">The View</param>
/// <param name="viewModel">The View model</param>
/// <param name="propertyName">The ViewModel command to bind</param>
/// <param name="controlName">The name of the control on the view</param>
/// <param name="withParameter">The ViewModel property to pass as the
/// param of the ICommand</param>
Expand Down Expand Up @@ -126,8 +131,25 @@ interface ICommandBinderImplementation : IEnableLogger
where TProp : ICommand;
}

/// <summary>
/// Used by the CommandBinder extension methods to handle binding View controls and ViewModel commands
/// </summary>
public class CommandBinderImplementation : ICommandBinderImplementation
{
/// <summary>
/// Bind a command from the ViewModel to an explicitly specified control
/// on the View.
/// </summary>
/// <returns>A class representing the binding. Dispose it to disconnect
/// the binding</returns>
/// <param name="view">The View</param>
/// <param name="viewModel">The View model</param>
/// <param name="controlProperty">The name of the control on the view</param>
/// <param name="vmProperty">The ViewModel command to bind</param>
/// <param name="withParameter">The ViewModel property to pass as the
/// param of the ICommand</param>
/// <param name="toEvent">If specified, bind to the specific event
/// instead of the default.</param>
public IReactiveBinding<TView, TViewModel, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(
TViewModel viewModel,
TView view,
Expand Down Expand Up @@ -157,6 +179,20 @@ public class CommandBinderImplementation : ICommandBinderImplementation
source, BindingDirection.OneWay, bindingDisposable);
}

/// <summary>
/// Bind a command from the ViewModel to an explicitly specified control
/// on the View.
/// </summary>
/// <returns>A class representing the binding. Dispose it to disconnect
/// the binding</returns>
/// <param name="view">The View</param>
/// <param name="viewModel">The View model</param>
/// <param name="controlProperty">The name of the control on the view</param>
/// <param name="vmProperty">The ViewModel command to bind</param>
/// <param name="withParameter">The ViewModel property to pass as the
/// param of the ICommand</param>
/// <param name="toEvent">If specified, bind to the specific event
/// instead of the default.</param>
public IReactiveBinding<TView, TViewModel, TProp> BindCommand<TView, TViewModel, TProp, TControl, TParam>(
TViewModel viewModel,
TView view,
Expand Down Expand Up @@ -303,7 +339,6 @@ public static IDisposable BindCommandToObject(ICommand command, object target, I
var mi = binder.GetType().GetTypeInfo().DeclaredMethods.First(x => x.Name == "BindCommandToObject" && x.IsGenericMethod);
mi = mi.MakeGenericMethod(new[] {eventArgsType});

//var ret = binder.BindCommandToObject<TEventArgs>(command, target, commandParameter, eventName);
var ret = (IDisposable) mi.Invoke(binder, new[] {command, target, commandParameter, eventName});
if (ret == null) {
throw new Exception(String.Format("Couldn't bind Command Binder for {0} and event {1}", type.FullName, eventName));
Expand Down

0 comments on commit 8d12b0e

Please sign in to comment.