Example #1
0
        ///// <summary>
        ///// 创建随机数组函数信息
        ///// </summary>
        //internal static readonly MethodInfo CreateSortedListMethod = typeof(MethodCache).GetMethod("createSortedList", BindingFlags.Static | BindingFlags.NonPublic);
        /// <summary>
        /// 创建随机数组
        /// </summary>
        /// <typeparam name="keyType"></typeparam>
        /// <typeparam name="valueType"></typeparam>
        /// <param name="config"></param>
        /// <returns></returns>
        //[AutoCSer.IOS.Preserve(Conditional = true)]
        internal static SortedList <keyType, valueType> createSortedListNull <keyType, valueType>(Config config)
        {
            object historyValue = config.TryGetValue(typeof(Dictionary <keyType, valueType>));

            if (historyValue != null)
            {
                return((SortedList <keyType, valueType>)historyValue);
            }
            uint length = (uint)AutoCSer.Random.Default.NextByte() & maxSize;

            if (length > 0)
            {
                SortedList <keyType, valueType> values = config.SaveHistory(new SortedList <keyType, valueType>((int)length));
                while (--length != 0)
                {
                    keyType key = Creator <keyType> .CreateNotNull(config);

                    valueType value;
                    if (!values.TryGetValue(key, out value))
                    {
                        values.Add(key, Creator <valueType> .CreateNull(config));
                    }
                }
                return(values);
            }
            return(null);
        }
Example #2
0
        ///// <summary>
        ///// 创建随机数组函数信息
        ///// </summary>
        //internal static readonly MethodInfo CreateArrayMethod = typeof(MethodCache).GetMethod("createArray", BindingFlags.Static | BindingFlags.NonPublic);
        /// <summary>
        /// 创建随机数组
        /// </summary>
        /// <typeparam name="valueType"></typeparam>
        /// <param name="config"></param>
        /// <returns></returns>
        //[AutoCSer.IOS.Preserve(Conditional = true)]
        internal static valueType[] createArrayNull <valueType>(Config config)
        {
            object historyValue = config.TryGetValue(typeof(valueType[]));

            if (historyValue != null)
            {
                return((valueType[])historyValue);
            }
            uint length = (uint)AutoCSer.Random.Default.NextByte() & maxSize;

            valueType[] value = config.SaveHistory(new valueType[length]);
            while (length != 0)
            {
                value[--length] = Creator <valueType> .CreateNull(config);
            }
            return(value);
        }
Example #3
0
        private static Dictionary <keyType, valueType> createDictionary <keyType, valueType>(Config config)
        {
            object historyValue = config.TryGetValue(typeof(Dictionary <keyType, valueType>));

            if (historyValue != null)
            {
                return((Dictionary <keyType, valueType>)historyValue);
            }
            uint length = (uint)AutoCSer.Random.Default.NextByte() & maxSize;
            Dictionary <keyType, valueType> values = config.SaveHistory(DictionaryCreator.CreateAny <keyType, valueType>((int)length));

            while (length-- != 0)
            {
                keyType key = Creator <keyType> .CreateNotNull(config);

                valueType value;
                if (!values.TryGetValue(key, out value))
                {
                    values.Add(key, Creator <valueType> .CreateNull(config));
                }
            }
            return(values);
        }
Example #4
0
 //[AutoCSer.IOS.Preserve(Conditional = true)]
 internal static valueType create <valueType>(Config config)
 {
     return(Creator <valueType> .CreateNull(config));
 }