Skip to content

Instantly share code, notes, and snippets.

@kgiszewski
Created July 12, 2018 16:51
Show Gist options
  • Save kgiszewski/ee938372df234dc2117304ccd48714be to your computer and use it in GitHub Desktop.
Save kgiszewski/ee938372df234dc2117304ccd48714be to your computer and use it in GitHub Desktop.
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);
}
}
@kgiszewski
Copy link
Author

kgiszewski commented Jul 12, 2018

Usage: content.GetVortoValueWithFallback<string>("someAlias");

Purpose: graceful degradation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment