mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.2 KiB
37 lines
1.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Volo.Abp.Localization
|
|
{
|
|
public class LocalizationResourceDictionary : Dictionary<Type, LocalizationResource>
|
|
{
|
|
public LocalizationResource Add<TResouce>([CanBeNull] string defaultCultureName = null)
|
|
{
|
|
return Add(typeof(TResouce), defaultCultureName);
|
|
}
|
|
|
|
public LocalizationResource Add(Type resourceType, [CanBeNull] string defaultCultureName = null)
|
|
{
|
|
if (ContainsKey(resourceType))
|
|
{
|
|
throw new AbpException("This resource is already added before: " + resourceType.AssemblyQualifiedName);
|
|
}
|
|
|
|
return this[resourceType] = new LocalizationResource(resourceType, defaultCultureName);
|
|
}
|
|
|
|
public LocalizationResource Get<TResource>()
|
|
{
|
|
var resourceType = typeof(TResource);
|
|
|
|
var resource = this.GetOrDefault(resourceType);
|
|
if (resource == null)
|
|
{
|
|
throw new AbpException("Can not find a resource with given type: " + resourceType.AssemblyQualifiedName);
|
|
}
|
|
|
|
return resource;
|
|
}
|
|
}
|
|
}
|