/// <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(this string source, string key, string category, CultureInfo culture)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                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;
        }
示例#2
0
 /// <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)
 {
 }