public object Parse(NameValueCollection data, string key, string prefix, out bool succeed) { string[] array = BindUtils.GetValues(data, key, prefix); succeed = true; if (array == null) { array = new string[0]; } return(array); }
public object Parse(NameValueCollection data, string key, string prefix, out bool succeed) { Array array = Array.CreateInstance(typeof(T), 0); string[] values = BindUtils.GetValues(data, key, prefix); if (values != null) { array = Array.CreateInstance(typeof(T), values.Length); for (int i = 0; i < values.Length; i++) { IEnumValue enumConvert = BindUtils.GetEnumConvert(typeof(T)); array.SetValue(enumConvert.GetValue(values[i], out succeed), i); } } succeed = true; return(array); }
public object Parse(NameValueCollection data, string key, string prefix, out bool succeed) { T[] array = new T[0]; succeed = true; string[] values = BindUtils.GetValues(data, key, prefix); succeed = (values != null && values.Length > 0); if (values != null) { array = new T[values.Length]; for (int i = 0; i < values.Length; i++) { T t; if (this.Parse(values[i], out t)) { array[i] = t; } } } return(array); }
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); }