Example #1
0
        /// <summary>
        /// 创建字符串定位器。
        /// </summary>
        /// <param name="resourceBaseType">给定的资源基础类型。</param>
        /// <returns>返回 <see cref="IStringLocalizer"/>。</returns>
        public IStringLocalizer Create(Type resourceBaseType)
        {
            var key = GenerateKey(resourceBaseType);

            return(_localizers.GetOrAdd(key, k =>
            {
                var manager = new ResourceDictionaryManager(resourceBaseType);
                return new DictionaryStringLocalizer(manager);
            }));
        }
Example #2
0
        /// <summary>
        /// 创建字符串定位器。
        /// </summary>
        /// <param name="baseTypeName">给定的资源基础名。</param>
        /// <param name="assemblyLocation">给定的资源程序集定位。</param>
        /// <returns>返回 <see cref="IStringLocalizer"/>。</returns>
        public IStringLocalizer Create(string baseTypeName, string assemblyLocation)
        {
            var key = GenerateKey(baseTypeName, assemblyLocation);

            return(_localizers.GetOrAdd(key, k =>
            {
                var baseType = Type.GetType(baseTypeName);

                var assemblyName = new AssemblyName(assemblyLocation);
                var assembly = Assembly.Load(assemblyName);

                var manager = new ResourceDictionaryManager(baseType, assembly);
                return new DictionaryStringLocalizer(manager);
            }));
        }
Example #3
0
 public DictionaryStringLocalizer(ResourceDictionaryManager manager)
 {
     Manager    = manager.NotNull(nameof(manager));
     Dictionary = manager.CreateDictionary();
 }