Created
October 7, 2019 19:51
-
-
Save TheFo2sh/e0a7a2f62e96fa39f2d4b33cb80c6423 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
[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