Exemplo n.º 1
0
        /// <summary>
        /// Box an entire array of type elements into an array of boxed elements.
        /// </summary>
        private static void CopyArray(Object source, Object destination, object defaultValue)
        {
            if (ReferenceEquals(source, null) && ReferenceEquals(destination, null))
            {
                return;
            }
            var length = JArray.GetLength(source);

            for (var i = 0; i < length; i++)
            {
                // Boxing is done by Get.
                var value = JArray.Get(source, i) ?? defaultValue;
                JArray.Set(destination, i, value);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Box an entire array of type elements into an array of boxed elements.
        /// </summary>
        private static object ConvertArray(Type boxType, Object primitiveArray, object defaultValue)
        {
            if (ReferenceEquals(primitiveArray, null))
            {
                return(null);
            }
            var length = JArray.GetLength(primitiveArray);
            var array  = JArray.NewInstance(boxType, length);

            for (var i = 0; i < length; i++)
            {
                // Boxing is done by Get.
                var value = JArray.Get(primitiveArray, i) ?? defaultValue;
                JArray.Set(array, i, value);
            }
            return(array);
        }
Exemplo n.º 3
0
        public static T[] ToArray <T>
        (
            this Object input
        )
            where T : Object
        {
            int length = Array.GetLength(input);
            var list   = new List <Object>(length);

            for (int index = 0; index < length; index++)
            {
                Object item = Array.Get(input, index);
                list.Add(item);
            }

            T[] output = list.Cast <T>().ToArray();

            return(output);
        }