Showing Warning Message In Your Xamarin App using Postsharp

Ahmed Fouad

In the previous article Adding Loader/Progress to your xamarin App using Postsharp we discussed how to use aspect oriented programming to make any async method showing progress without investing any effort.

In this article i will show you how to show a warning message before the execution of a method using Aspect oriented programming.

The aspect is obvious we use the Acr user dialogs library to show the confirmation message and depend on the user accept or not we execute the target method or end the computation.

[RequireUserConfirmation("Delete User","Are you sure , you want to delete" , "Delete","Cancel")
public async Task DeleteUser(User user)
{
await this.Users.DeleteAsync(user);
}

In order to get this code to work you must install Postsharp in your visual studio and install these nuget packages

Ahmed Fouad

Written by

Hello, I’m Ahmed. I’m a software engineer living in Vienna, Austria. I am a fan of technology, web development, and programming. I’m also interested in xamarin

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade