示例#1
0
        /// <summary>
        /// Gets this setting's value as an array of a specific type.
        /// </summary>
        public T[] GetValueArray <T>()
        {
            var type = typeof(T);

            if (type.IsArray)
            {
                throw CreateJaggedArraysNotSupportedEx(type);
            }

            int myArraySize = this.ArraySize;

            if (myArraySize < 0)
            {
                return(null);
            }

            var values = new T[myArraySize];

            if (myArraySize > 0)
            {
                var enumerator = new SettingArrayEnumerator(mRawValue);
                while (enumerator.Next())
                {
                    values[enumerator.Index] = (T)CreateObjectFromString(enumerator.Current, type);
                }
            }

            return(values);
        }
示例#2
0
        /// <summary>
        /// Gets this setting's value as an array of a specific type.
        /// </summary>
        public object[] GetValueArray(Type elementType)
        {
            if (elementType.IsArray)
            {
                throw CreateJaggedArraysNotSupportedEx(elementType);
            }

            int myArraySize = this.ArraySize;

            if (ArraySize < 0)
            {
                return(null);
            }

            var values = new object[myArraySize];

            if (myArraySize > 0)
            {
                var enumerator = new SettingArrayEnumerator(mRawValue);
                while (enumerator.Next())
                {
                    values[enumerator.Index] = CreateObjectFromString(enumerator.Current, elementType);
                }
            }

            return(values);
        }