Example #1
0
        /// <summary>
        /// Converts specified value into AnyValueMap.
        /// </summary>
        /// <param name="value">value to be converted</param>
        /// <returns>a newly created AnyValueMap.</returns>
        /// See <see cref="SetAsObject(object)"/>
        public static AnyValueMap FromValue(object value)
        {
            var result = new AnyValueMap();

            result.SetAsObject(value);
            return(result);
        }
Example #2
0
        /// <summary>
        /// Creates a new AnyValueMap from a list of key-value pairs called tuples.
        /// </summary>
        /// <param name="tuples">a list of values where odd elements are keys and the following
        /// even elements are values</param>
        /// <returns>a newly created AnyValueArray.</returns>
        public static AnyValueMap FromTuples(params object[] tuples)
        {
            var result = new AnyValueMap();

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

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

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

                result.SetAsObject(name, value);
            }

            return(result);
        }