Skip to content

Instantly share code, notes, and snippets.

@TheFo2sh
Created October 7, 2019 19:51
Show Gist options
  • Save TheFo2sh/e0a7a2f62e96fa39f2d4b33cb80c6423 to your computer and use it in GitHub Desktop.
Save TheFo2sh/e0a7a2f62e96fa39f2d4b33cb80c6423 to your computer and use it in GitHub Desktop.
[Serializable]
public class RequireUserConfirmationAttribute : MethodInterceptionAspect
{
private string message;
private string cancelText;
private string okText;
private string title;
public RequireUserConfirmationAttribute(string title,string message,string okText, string cancelText)
{
this.message = message;
this.cancelText = cancelText;
this.okText = okText;
this.title = title;
}
public override void OnInvoke(MethodInterceptionArgs args)
{
UserDialogs.Instance.Confirm(new ConfirmConfig()
{
Message = this.message,
CancelText = this.cancelText,
OkText = this.okText,
Title = this.title,
OnAction = b =>
{
if (b)
args.Proceed();
}
});
}
public override async Task OnInvokeAsync(MethodInterceptionArgs args)
{
var result=await UserDialogs.Instance.ConfirmAsync(new ConfirmConfig()
{
Message = this.message,
CancelText = this.cancelText,
OkText = this.okText,
Title = this.title,
});
if (result)
await args.ProceedAsync();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment