I have an Interface for a WCF service
public interface IAuthenticationService
{
void Authenticate(Action<bool, Exception> callback, string UserName,string Password);
}
I have an implementation
public class AuthenticationService : IAuthenticationService
{
public void Authenticate(Action<bool, Exception> callback, string Name, string Password)
{
MvcWebAuthenticate.AuthenticationServiceClient authService = new MvcWebAuthenticate.AuthenticationServiceClient();
authService.CookieContainer = AuthCookie.CookieJar;
authService.LoginCompleted += (s, e) =>
{
if (e.Result == false)
{
callback(false, e.Error);
}
else
{
callback(true, null);
}
};
authService.LoginAsync(Name, Password, "", true);
}
}
From my view model i want to call service above and pass username and password, but I don’t understand how to write a lambda expression in order to pass parameters and get a “callback” Action back.
if i didnt have UserName and Password i could write this code:
_dataService.Authenticate(
(authenticated, error) =>
{
if (error != null)
{ }
});
But how to achieve same when i need to pass parameters?
Thank you
Unless I’m misunderstanding the issue, you should be able to just do this: