Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There is a method call in a a function, I want to restrict it call based on the value set in the webConfig file.If it is true,it should be called else not.

What I have tried:

private IEnumerable<Contracts.Models.Translation> GetTranslationsIfEmpty(IEnumerable<Contracts.Models.Translation> translations, string locale, Expression<Func<Contracts.Models.Translation, Boolean>> where)
{

    if (!locale.Equals(EnglishLocale, StringComparison.OrdinalIgnoreCase) && !translations.Any())
    {
        var englishTranslations = _translationService.Get(where);
        translations = GetTranslations(englishTranslations.ToArray(), locale);
        AddNewTranslations(translations);
    }
    return translations;
}


I want to restrict the call of AddNewTranslation() in the function based on the appSetting in webConfig file
Posted
Comments
F-ES Sitecore 17-Jan-18 7:46am    
Check the app setting inside the function and if it indicates the function is disabled throw an exception. You could consider making this a method attribute if you want to re-use the concept. It's quite a straightforwrad task so what exactly do you need help doing?
Avinash Gupta 17-Jan-18 7:52am    
What do you mean by app setting inside the function?
F-ES Sitecore 17-Jan-18 8:37am    
I'm assuming you are going to create an app setting that dictates if this method is disabled, so in your function read the value of that app setting and act according it its value.
Avinash Gupta 18-Jan-18 1:38am    
How to read the value of that appsetting?
F-ES Sitecore 18-Jan-18 4:28am    
google "c# read appsetting".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900