Skip to content

Commit

Permalink
add support for input, output args on commands
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvreony committed Jun 7, 2024
1 parent 9447fbb commit dc79350
Showing 1 changed file with 57 additions and 4 deletions.
61 changes: 57 additions & 4 deletions src/Vetuviem.Core/CommandBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ namespace Vetuviem.Core
/// Represents a command binding between a control and a viewmodel.
/// </summary>
/// <typeparam name="TViewModel">The type for the viewmodel.</typeparam>
public sealed class CommandBinding<TViewModel> : ICommandBinding<TViewModel, ICommand>
public class CommandBinding<TViewModel> : CommandBinding<TViewModel, Unit, Unit>
where TViewModel : class
{
private readonly Expression<Func<TViewModel, ReactiveCommand<Unit, Unit>?>> _viewModelBinding;
private readonly string? _toEvent;

/// <summary>
/// Initializes a new instance of the <see cref="CommandBinding{TViewModel}"/> class.
/// </summary>
Expand All @@ -29,6 +26,62 @@ public sealed class CommandBinding<TViewModel> : ICommandBinding<TViewModel, ICo
public CommandBinding(
Expression<Func<TViewModel, ReactiveCommand<Unit, Unit>?>> viewModelBinding,
string? toEvent = null)
: base(
viewModelBinding,
toEvent)
{
}
}

/// <summary>
/// Represents a command binding between a control and a viewmodel.
/// </summary>
/// <typeparam name="TViewModel">The type for the viewmodel.</typeparam>
/// <typeparam name="TResult">
/// The type of the values that are the result of command execution.
/// </typeparam>
public class CommandBinding<TViewModel, TResult> : CommandBinding<TViewModel, Unit, TResult>
where TViewModel : class
{
/// <summary>
/// Initializes a new instance of the <see cref="CommandBinding{TViewModel, TResult}"/> class.
/// </summary>
/// <param name="viewModelBinding">Expression for the View Model binding.</param>
/// <param name="toEvent">If specified, bind to the specific event instead of the default.</param>
public CommandBinding(
Expression<Func<TViewModel, ReactiveCommand<Unit, TResult>?>> viewModelBinding,
string? toEvent = null)
: base(
viewModelBinding,
toEvent)
{
}
}

/// <summary>
/// Represents a command binding between a control and a viewmodel.
/// </summary>
/// <typeparam name="TViewModel">The type for the viewmodel.</typeparam>
/// <typeparam name="TParam">
/// The type of parameter values passed in during command execution.
/// </typeparam>
/// <typeparam name="TResult">
/// The type of the values that are the result of command execution.
/// </typeparam>
public class CommandBinding<TViewModel, TParam, TResult> : ICommandBinding<TViewModel, ICommand>
where TViewModel : class
{
private readonly Expression<Func<TViewModel, ReactiveCommand<TParam, TResult>?>> _viewModelBinding;
private readonly string? _toEvent;

/// <summary>
/// Initializes a new instance of the <see cref="CommandBinding{TViewModel, TParam, TResult}"/> class.
/// </summary>
/// <param name="viewModelBinding">Expression for the View Model binding.</param>
/// <param name="toEvent">If specified, bind to the specific event instead of the default.</param>
public CommandBinding(
Expression<Func<TViewModel, ReactiveCommand<TParam, TResult>?>> viewModelBinding,
string? toEvent = null)
{
_viewModelBinding = viewModelBinding;
_toEvent = toEvent;
Expand Down

0 comments on commit dc79350

Please sign in to comment.