I have a constructor of RelayCommand set as:
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
And in another script I have:
private Server _server;
public RelayCommand ConnectToServerCommand {get; set;}
public MainViewModel() // constructor
{
_server = new Server();
//this syntax is confusing to me - not sure what it's doing
ConnectToServerCommand = new(o => _server.Connect());
}
I don't really understand the syntax for the ConnectToServerCommand in the MainViewModel constructor.
The RelayCommand takes in an Action with an object parameter type, yet the _server.Connect() method has this signature:
// Server
public void Connect()
Why does it allow this method to be used when it does not have an object as one of it's arguments? Given the action is set to Action<object>. How is it considering this a valid method signature?
I am still new to this - so I think the lambda expression is confusing me a little but, not sure how they connect together here.