public LocalizedPropertyService(IUnitOfWork unitOfWork,
                                 ILocalizedPropertyRepository localizedPropertyRepository, ICacheManager cacheManager) : base(unitOfWork,
                                                                                                                              localizedPropertyRepository)
 {
     _unitOfWork = unitOfWork;
     _localizedPropertyRepository = localizedPropertyRepository;
     _cacheManager = cacheManager;
 }
Beispiel #2
0
 public EntityLocalizer(
     ILocalizedPropertyRepository localizedPropertyRepository,
     ILanguageService languageService,
     IEntityLocalizedPropertyInfoResolver localiedPropertiesInfoResolver,
     IOptionsSnapshot <LocalizationOptions> localizationOptions)
 {
     _localizedPropertyRepository    = localizedPropertyRepository;
     _languageService                = languageService;
     _localiedPropertiesInfoResolver = localiedPropertiesInfoResolver;
     _localizationOptions            = localizationOptions.Value;
 }
 public ModelLocalizer(
     ILocalizedPropertyRepository localizedPropertyRepository,
     IEntityLocalizer entityLocalizer,
     ILanguageRepository languageRepository,
     ILanguageService languageService,
     IModelLocalizedPropertyResolver modelLocalizedPropertyResolver,
     IMapper mapper,
     IOptionsSnapshot <LocalizationOptions> localizationOptions)
 {
     _localizedPropertyRepository    = localizedPropertyRepository;
     _entityLocalizer                = entityLocalizer;
     _languageRepository             = languageRepository;
     _languageService                = languageService;
     _modelLocalizedPropertyResolver = modelLocalizedPropertyResolver;
     _mapper = mapper;
     _localizationOptions = localizationOptions.Value;
 }
    public string Resolve(Mapping source, object destination, EntityInfo sourceMember, string destMember,
                          ResolutionContext context)
    {
        context.Items.TryGetValue("Language", out object languageObject);
        context.Items.TryGetValue("Repository", out object repositoryObject);
        ILocalizedPropertyRepository repository = repositoryObject as ILocalizedPropertyRepository;
        LanguageDTO language = languageObject as LanguageDTO;

        if (language == null || repository == null)
        {
            throw new ArgumentNullException($"Language and LocalizationRepository as AutoMapper Parameter");
        }
        if (source.Id == 0)
        {
            return(sourceMember.DefaultValue);
        }
        //Get the value from the DB
        return(LocalizationExtension.GetLocalized(sourceMember.LocaleKey, sourceMember.LocaleKeyGroup, sourceMember.DefaultValue, source.Id, language, repository));
    }
 public LocalizedPropertyService(IUnitOfWork unitOfWork, ILocalizedPropertyRepository LocalizedPropertyRepository) : base(unitOfWork, LocalizedPropertyRepository)
 {
     this._unitOfWork = unitOfWork;
     this._localizedPropertyRepository = LocalizedPropertyRepository;
 }
 public static void Localice(IMappingOperationOptions <object, object> opt, LanguageDTO language, ILocalizedPropertyRepository localizedPropertyRepository)
 {
     opt.Items["Language"]   = language;
     opt.Items["Repository"] = localizedPropertyRepository;
 }
    public static string GetLocalized(string localeKey, string localeKeyGroup, string defaultValue, long entityId, LanguageDTO language, ILocalizedPropertyRepository localizedPropertyRepository)
    {
        var resultStr = String.Empty;

        if (language != null)
        {
            resultStr = localizedPropertyRepository.GetLocalizedValue(language, entityId, localeKeyGroup, localeKey);
        }
        if (string.IsNullOrEmpty(resultStr))
        {
            resultStr = defaultValue;
        }
        return(resultStr);
    }