today i was looking for some projects with ilspy i did not understand how Actions can be used like this, in one class this method is called
public void Login(Action success, Action<bool> failure)
{
if (!FB.IsInitialized)
{
Debug.Log("[FB] Not yet initialized. Will init again!");
FB.Init(new InitDelegate(this.OnInitComplete), null, null);
return;
}
new LoginWithReadPermissions(this.READ_PERMISSIONS, delegate
{
ServiceLocator.GetDB().SetBool("facebookBound", true, false);
this.OnLoginCompleted(success, failure);
}, delegate
{
failure(false);
});
}
and this is the other class that is called by above method
public class LoginWithReadPermissions
{
private readonly Action _failureCallback;
private readonly Action _successCallback;
public LoginWithReadPermissions(string[] scope, Action success, Action failure)
{
this._successCallback = success;
this._failureCallback = failure;
FB.LogInWithReadPermissions(scope, new FacebookDelegate<ILoginResult>(this.AuthCallback));
}
private void AuthCallback(ILoginResult result)
{
if (result.Error == null && FB.IsLoggedIn)
{
this._successCallback();
}
else
{
this._failureCallback();
}
}
}
Can someone please explain what is going on there I have never faced with this kind of Action usage. Thanks for replies.