dimanche 27 septembre 2020

How to prevent method invoking when Attribute return false? [duplicate]

I have a software that requires a license key validation on some methods. It a little bit uncomfortable to write a general wrapper for this purpose, so I want to write something like this:

    [EnsureThat(LicenseKeyAdded = true)]
    public static void SomeSeriousMethod()
    {
       // My very confidential code
    }

LicenseKeyAdded is a property inside the class, that was set somewhere outside. And the main idea is not to execute this method when the attribute's result is false (display alert message instead)





Aucun commentaire:

Enregistrer un commentaire