Created
July 12, 2018 16:51
-
-
Save kgiszewski/ee938372df234dc2117304ccd48714be 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
public static T GetVortoValueWithFallback<T>(this IPublishedContent content, string alias) | |
{ | |
if (content == null) | |
{ | |
LogHelper.Info<T>($"Vorto can't use null content with Alias => {alias}"); | |
return default(T); | |
} | |
try | |
{ | |
return content.GetVortoValue<T>(alias, fallbackCultureName: ConfigurationManager.AppSettings["fallbackVortoLanguage"]); | |
} | |
catch (Exception ex) | |
{ | |
LogHelper.Info<T>($"Vorto had an issue with Alias => {alias}"); | |
LogHelper.Error<T>(ex.Message, ex); | |
return default(T); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
content.GetVortoValueWithFallback<string>("someAlias");
Purpose: graceful degradation.