Removes umbraco.cms.businesslogic.Dictionary !!!

This commit is contained in:
Shannon
2016-05-19 19:20:49 +02:00
parent 9ba095508e
commit b268f76aa9
15 changed files with 139 additions and 468 deletions

View File

@@ -0,0 +1,30 @@
using System.Linq;
namespace Umbraco.Core.Models
{
public static class DictionaryItemExtensions
{
/// <summary>
/// Returns the translation value for the language id, if no translation is found it returns an empty string
/// </summary>
/// <param name="d"></param>
/// <param name="languageId"></param>
/// <returns></returns>
public static string GetTranslatedValue(this IDictionaryItem d, int languageId)
{
var trans = d.Translations.FirstOrDefault(x => x.LanguageId == languageId);
return trans == null ? string.Empty : trans.Value;
}
/// <summary>
/// Returns the default translated value based on the default language
/// </summary>
/// <param name="d"></param>
/// <returns></returns>
public static string GetDefaultValue(this IDictionaryItem d)
{
var defaultTranslation = d.Translations.FirstOrDefault(x => x.Language.Id == 1);
return defaultTranslation == null ? string.Empty : defaultTranslation.Value;
}
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;