Exemple #1
0
        /// <summary>
        /// Sets the value for a given qualifier
        /// </summary>
        /// <param name="qualifier">Qualifies the value to be set</param>
        /// <param name="value">The new value to override the old value with</param>
        public void Set(Qualifier.WithKey qualifier, String value)
        {
            var locale = qualifier.Locale ?? Locales.GetCurrentLocale();
            var part   = qualifier.Part ?? Parts.GetCurrentPart();

            Values.SetValue(new Qualifier.Unique(part, locale, qualifier.Key), value);
        }
Exemple #2
0
        /// <summary>
        /// Gets the current spec for a specified key, overriding the current part and locale
        /// </summary>
        /// <param name="qualifier">Qualifier to get specs for, should at least contain the key.</param>
        /// <param name="defaultValue">If the localization does not yet exist, create with default value</param>
        /// <returns></returns>
        public QualifiedValue GetQualified(Qualifier.WithKey qualifier, String defaultValue = null)
        {
            var locale          = qualifier.Locale ?? Locales.GetCurrentLocale();
            var part            = qualifier.Part ?? Parts.GetCurrentPart();
            var resultQualifier = new Qualifier.Unique(part, locale, qualifier.Key);

            try {
                var value = Values.GetQualifiedValue(resultQualifier, defaultValue);
                if (value == null)
                {
                    throw new ValueNotFoundException(qualifier);
                }
                Logger.Log(value.Qualifier);
                return(value);
            }
            catch (ValueNotFoundException) {
                Notifier.NotifyMissing(resultQualifier);
                return(new QualifiedValue(resultQualifier, defaultValue ?? String.Format("[{0}]", qualifier.Key)));
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets the current value for a specified key, overriding the current part and locale
        /// </summary>
        /// <param name="qualifier">Qualifier for the value to get. Should have at least its key set</param>
        /// <param name="defaultValue">If the localization does not yet exist, create with default value</param>
        /// <returns></returns>
        public String Get(Qualifier.WithKey qualifier, String defaultValue = null)
        {
            var value = GetQualified(qualifier, defaultValue);

            return(value == null ? String.Empty : value.Value);
        }
        /// <summary>
        /// Gets the current value for a specified key, overriding the current part and locale
        /// </summary>
        /// <param name="qualifier">Qualifier for the value to get. Should have at least its key set</param>
        /// <returns></returns>
        public String Get(Qualifier.WithKey qualifier)
        {
            var value = GetQualified(qualifier);

            return(value == null ? String.Empty : value.Value.DecodedContent);
        }