/// <summary> /// Localizes the specified element. /// </summary> /// <param name="element">The element.</param> /// <returns></returns> public static string Localize(Element element) { return Map(element.Value,element.Name, element.Category, CultureInfo.GetCultureInfo(element.Culture)).Value; }
/// <summary> /// Maps the specified source. /// </summary> /// <param name="source">The source.</param> /// <param name="key">The key.</param> /// <param name="category">The category.</param> /// <param name="culture">The culture.</param> /// <returns></returns> public static Element Map(string source, string key, string category, CultureInfo culture) { if (string.IsNullOrEmpty(key) || key.Trim() == string.Empty) { return Element.Empty; } var repository = ElementRepository.DefaultRepository; var element = repository.Get(key, category, culture.Name); if (element == null) { element = new Element() { Name = source, Category = category, Culture = culture.Name, Value = source }; repository.Add(element); } return element; }
/// <summary> /// Initializes a new instance of the <see cref="ElementCacheKey" /> class. /// </summary> /// <param name="element">The element.</param> public ElementCacheKey(Element element) : this(element.Name, element.Category, element.Culture) { }