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
 private static Nullable <valueType> createNullable <valueType>(Config config) where valueType : struct
 {
     if (createBool())
     {
         return(Creator <valueType> .CreateNotNull(config));
     }
     return(new Nullable <valueType>());
 }
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);
        }