public void TestGetAndSet()
        {
            var value = new MultiString();

            Assert.Null(value.Get("en"));

            value.Put("ru", "Russian");
            Assert.Equal("Russian", value.Get("ru"));
            Assert.Equal("Russian", value.Get("en"));
            Assert.Equal("Russian", value.Get("pt"));

            value.Put("en", "English");
            Assert.Equal("Russian", value.Get("ru"));
            Assert.Equal("English", value.Get("en"));
            Assert.Equal("English", value.Get("pt"));
        }
Exemple #2
0
        /// <summary>
        /// Creates a new MultiString object from language-translation pairs (tuples) specified as array.
        /// </summary>
        /// <param name="tuples">an array that contains language-translation tuples.</param>
        /// <returns>a MultiString Object.</returns>
        public static MultiString FromTuplesArray(string[] tuples)
        {
            var result = new MultiString();

            if (tuples == null || tuples.Length == 0)
            {
                return(result);
            }

            for (int index = 0; index < tuples.Length; index += 2)
            {
                if (index + 1 >= tuples.Length)
                {
                    break;
                }

                var name  = StringConverter.ToString(tuples[index]);
                var value = StringConverter.ToNullableString(tuples[index + 1]);

                result[name] = value;
            }

            return(result);
        }
Exemple #3
0
 /// <summary>
 /// Creates a new MultiString object from language-translation pairs (tuples).
 /// </summary>
 /// <param name="tuples">an array that contains language-translation tuples.</param>
 /// <returns>a MultiString Object.</returns>
 /// See <see cref="FromTuplesArray"/>
 public static MultiString FromTuples(params string[] tuples)
 {
     return(MultiString.FromTuplesArray(tuples));
 }