Created
July 8, 2020 17:40
-
-
Save guntidheerajkumar/fc648ff3e24bf7cc5c6f22e0cca9a26e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Mobile.Commands | |
{ | |
public class CustomCommand<T> : ICommand | |
{ | |
private Action _action; | |
private Action<object> _newAction; | |
private string _activityName; | |
private bool _canExecute; | |
private readonly Func<T, Task> _executeTask; | |
public event EventHandler CanExecuteChanged; | |
public CustomCommand(string activityName, Func<T, Task> executeTask) | |
{ | |
_executeTask = executeTask; | |
_activityName = activityName; | |
_canExecute = true; | |
} | |
public bool CanExecute(object parameter) | |
{ | |
return _canExecute; | |
} | |
public void Execute(object parameter) | |
{ | |
Analytics.TrackEvent($"Perforced action : {_activityName}"); | |
_executeTask.Invoke((T)parameter); | |
} | |
} | |
public class CustomCommand : ICommand | |
{ | |
private Action _action; | |
private Action<object> _newAction; | |
private string _activityName; | |
private bool _canExecute; | |
public event EventHandler CanExecuteChanged; | |
public CustomCommand(string activityName, Action action) | |
{ | |
_activityName = activityName; | |
_action = action; | |
_canExecute = true; | |
} | |
public CustomCommand(string activityName, Action<object> action) | |
{ | |
_activityName = activityName; | |
_newAction = action; | |
_canExecute = true; | |
} | |
public bool CanExecute(object parameter) | |
{ | |
return _canExecute; | |
} | |
public void Execute(object parameter) | |
{ | |
Analytics.TrackEvent($"Perforced action : {_activityName}"); | |
_action(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment