コード例 #1
0
        public virtual string GetResource(string resourceName, int languageId, string defaultValue = "",
                                          bool returnEmptyIfNotFound = false, bool logIfNotFound = false)
        {
            var result = FindByName(resourceName, languageId, logIfNotFound)?.ResourceValue ?? string.Empty;

            if (string.IsNullOrEmpty(result))
            {
                if (!string.IsNullOrEmpty(defaultValue))
                {
                    result = defaultValue;
                }
                else
                {
                    if (!returnEmptyIfNotFound)
                    {
                        var defaultLanguageValue = FindByName(resourceName, _languagesService.GetDefaultLanguage().Id, logIfNotFound)?.ResourceValue ?? string.Empty;
                        if (!string.IsNullOrEmpty(defaultLanguageValue))
                        {
                            result = defaultLanguageValue;
                        }
                        else
                        {
                            result = resourceName;
                        }
                    }
                }
            }
            return(result);
        }