This is an add-in for Fody
Injects ICommand properties and implementations for use in MVVM applications.
Nuget package http://nuget.org/packages/Commander.Fody
public class SurveyViewModel
{
[OnCommandCanExecute("SubmitCommand")]
public bool CanSubmit()
{
...
}
[OnCommand("SubmitCommand")]
public void OnSubmit(){
...
}
}
With a command implementation in assembly like:
public class DelegateCommand : ICommand
{
...
public DelegateCommand(Action execute):this(execute, null)
{
}
public DelegateCommand(Action execute, Func<bool> canExecute)
{
...
}
public void Execute(object parameter)
{
...
}
public bool CanExecute(object parameter)
{
...
}
}
public class SurveyViewModel
{
SurveyViewModel()
{
<Commander_Fody>InitializeCommands();
}
public ICommand SubmitCommand {get;set;}
public bool CanSubmit(){
...
}
public void OnSubmit(){
...
}
private void <Commander_Fody>InitializeCommands()
{
if (this.SubmitCommand == null)
{
this.SubmitCommand = new DelegateCommand(new Action(this.OnSubmit), new Func<bool>(this.CanSubmit));
}
}
}
TODO