public object Parse(NameValueCollection data, string key, string prefix, out bool succeed) { IList <T> list = null; succeed = true; Type type = Type.GetType("System.Collections.Generic.List`1"); type = type.MakeGenericType(new Type[] { typeof(T) }); list = (IList <T>)Activator.CreateInstance(type); int num = 0; Dictionary <PropertyInfo, string[]> dictionary = new Dictionary <PropertyInfo, string[]>(); foreach (PropertyInfo current in ToIList <T> .Properties) { string[] array = BindUtils.GetValues(data, current.Name, prefix); if (array != null && array.Length > num) { num = array.Length; } dictionary.Add(current, array); } for (int i = 0; i < num; i++) { NameValueCollection nameValueCollection = new NameValueCollection(); foreach (PropertyInfo current in ToIList <T> .Properties) { string[] array = dictionary[current]; if (array != null && i < array.Length) { nameValueCollection.Add(current.Name, array[i]); } } T item = BinderHelper.CreateInstance <T>(nameValueCollection); list.Add(item); } return(list); }
internal static T CreateInstance <T>(NameValueCollection data, string prefix) { return((T)BinderHelper.CreateInstance(typeof(T), data, prefix)); }
internal static T CreateInstance <T>(NameValueCollection data) { return(BinderHelper.CreateInstance <T>(data, null)); }
internal static object CreateInstance(Type type, NameValueCollection data) { return(BinderHelper.CreateInstance(type, data, null)); }