public static IList GetList(Type type, NameValueCollection data, string prefix) { IConvert listConvert = BinderHelper.GetListConvert(type); bool flag; return((IList)listConvert.Parse(data, "", prefix, out flag)); }
public static object GetObject(Type type, string prefix) { object obj = Activator.CreateInstance(type); BinderHelper.Full(obj, HttpContext.Current.Request.Params, prefix, false); return(obj); }
static BinderHelper() { BinderHelper.mIListConvert = new Dictionary <Type, IConvert>(); BinderHelper.AddCustomConvert(new Assembly[] { typeof(BinderHelper).Assembly }); }
public static T GetValue <T>(string key) { T result = default(T); object value = BinderHelper.GetValue(typeof(T), key); if (value != null) { result = (T)value; } return(result); }
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); }
public void FullValue(object source, System.Collections.Specialized.NameValueCollection data, string Prefix, bool ispostback) { BinderHelper.Full(source, data, Prefix, ispostback); }
public static T GetObject <T>(string prefix) where T : new() { return((T)BinderHelper.GetObject(typeof(T), prefix)); }
public static T GetObject <T>() where T : new() { return(BinderHelper.GetObject <T>(null)); }
internal static T CreateInstance <T>(NameValueCollection data) { return(BinderHelper.CreateInstance <T>(data, null)); }
internal static T CreateInstance <T>(NameValueCollection data, string prefix) { return((T)BinderHelper.CreateInstance(typeof(T), data, prefix)); }
internal static object CreateInstance(Type type, NameValueCollection data) { return(BinderHelper.CreateInstance(type, data, null)); }
public static IList <T> GetList <T>(NameValueCollection data, string prefix) where T : new() { return((IList <T>)BinderHelper.GetList(typeof(T), data, prefix)); }
public static IList <T> GetList <T>() where T : new() { return(BinderHelper.GetList <T>(HttpContext.Current.Request.Params, "")); }