Example #1
0
        public void GetValueThrowsArgumentNullException()
        {
            Func <string> func = null;

            Assert.Throws <ArgumentNullException>(() => DictionaryUtils.GetValue(null, "B", string.Empty));
            Assert.Throws <ArgumentNullException>(() => DictionaryUtils.GetValue(new Dictionary <string, string>(), "B", func));
        }
Example #2
0
        /// <summary>
        /// Gets a translation from the translation set, or <code>null</code> if the translation doesn't exist.
        /// </summary>
        /// <param name="key">
        /// The key (ID) of the translation to retrieve
        /// </param>
        public virtual string this[string key]
        {
            get
            {
                string translation = DictionaryUtils.GetValue(translations, key);

                if (translation == null)
                {
                    translation = GetParentTranslation(key);
                }

                return(translation);
            }
        }
Example #3
0
        public void GetValue()
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>
            {
                { "A", "1" },
                { "B", "2" },
                { "C", "3" }
            };

            Assert.AreEqual("1", DictionaryUtils.GetValue(dictionary, "A", string.Empty));
            Assert.AreEqual("2", DictionaryUtils.GetValue(dictionary, "B", string.Empty));
            Assert.AreEqual("3", DictionaryUtils.GetValue(dictionary, "C", string.Empty));

            Assert.AreEqual("Default", DictionaryUtils.GetValue(dictionary, "D", "Default"));
        }
Example #4
0
        public static AbstractTranslationSet GetTranslationSet(string translationLanguage)
        {
            AbstractTranslationSet translations = null;

            if (translationLanguage != null)
            {
                translations = DictionaryUtils.GetValue(langToTranslationMap, translationLanguage);

                if (translations == null)
                {
                    translations = new ModifiableTranslationSet(translationLanguage);
                }
            }

            return(translations);
        }
Example #5
0
        public override Uri ResolveUri(Uri baseUri, string relativeUri)
        {
            Uri uri = DictionaryUtils.GetValue(relativeToUriMap, relativeUri);

            return((uri == null) ? base.ResolveUri(baseUri, relativeUri) : uri);
        }