public bool GetValueTypeValue(System.Collections.Specialized.NameValueCollection data, string Prefix, out object value) { IConvert convert = null; value = null; Type createtype = Handler.Property.PropertyType; if (Binder != null && Binder.Convert == null && Binder.Fungible != null) { createtype = Binder.Fungible; } bool succed = false; if (Binder != null && !string.IsNullOrEmpty(Binder.Prefix)) { Prefix = Binder.Prefix; } if (Binder != null) { convert = Binder.GetConvert(); } if (convert == null) { if (BindUtils.Converts.ContainsKey(createtype)) { convert = BindUtils.Converts[createtype]; } } if (convert != null) { value = convert.Parse(data, Handler.Property.Name, Prefix, out succed); } else { if (createtype.IsEnum) { Type tomenutype = typeof(ToEnum <>).MakeGenericType(createtype); convert = (IConvert)Activator.CreateInstance(tomenutype); BindUtils.AddCustomConvert(createtype, convert); object pvalue = convert.Parse(data, Handler.Property.Name, Prefix, out succed); if (succed) { value = Convert.ChangeType(pvalue, createtype); } } } return(succed); }
public object GetValue(NameValueCollection data) { object value = null; bool succeed = false; if (Binder != null) { value = Binder.GetConvert().Parse(data, Info.Name, Binder.Prefix, out succeed); if (!succeed && Binder.Fungible != null) { value = Activator.CreateInstance(Binder.Fungible); } return(value); } else { IConvert convert = BindUtils.GetConvert(Info.PropertyType); if (convert != null) { value = convert.Parse(data, Info.Name, null, out succeed); } else { if (Info.PropertyType.IsValueType) { value = BinderHelper.GetValue(Info.PropertyType, Info.Name); } else { value = GetObject(data); } } } return(value); }
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 GetValue(Type type, string key) { object result = null; IConvert convert = null; object obj = null; if (!BindUtils.Converts.TryGetValue(type, out convert)) { if (type.IsEnum) { Type type2 = typeof(ToEnum <>).MakeGenericType(new Type[] { type }); convert = (IConvert)Activator.CreateInstance(type2); BindUtils.AddCustomConvert(type, convert); } } bool flag = false; if (convert != null) { obj = convert.Parse(HttpContext.Current.Request.Params, key, null, out flag); } if (flag) { result = obj; } return(result); }
public static IList <T> FullList <T>(NameValueCollection data, string prefix) where T : new() { IConvert convert = GetListConvert <T>(); bool succeed; return((IList <T>)convert.Parse(data, "", prefix, out succeed)); }
private bool GetClassValue(System.Collections.Specialized.NameValueCollection data, string Prefix, out object value) { IConvert convert = null; value = null; Type createtype = Info.ParameterType; if (Binder != null && Binder.Convert == null && Binder.Fungible != null) { createtype = Binder.Fungible; } bool succed = false; if (Binder != null && !string.IsNullOrEmpty(Binder.Prefix)) { Prefix = Binder.Prefix; } if (Binder != null) { convert = Binder.GetConvert(); } if (convert == null) { if (BindUtils.Converts.ContainsKey(createtype)) { convert = BindUtils.Converts[createtype]; } } if (convert != null) { value = convert.Parse(data, Info.Name, Prefix, out succed); } else if (createtype.IsArray) { if (createtype.GetElementType().IsEnum) { Type toenumtype = typeof(ToEnumArray <>).MakeGenericType(createtype.GetElementType()); IConvert tea = (IConvert)Activator.CreateInstance(toenumtype); BindUtils.AddCustomConvert(toenumtype, tea); value = tea.Parse(data, Info.Name, Prefix, out succed); } } else { if (createtype.IsClass && !createtype.IsInterface && !createtype.IsAbstract) { ClassBinder cb = BindUtils.GetBinder(createtype); succed = true; value = cb.CreateObject(data, Prefix); } } return(succed); }
private bool GetClassValue(System.Collections.Specialized.NameValueCollection data, string Prefix, out object value) { IConvert convert = null; value = null; Type createtype = Info.ParameterType; if (Binder != null && Binder.Convert == null && Binder.Fungible != null) { createtype = Binder.Fungible; } bool succed = false; if (Binder != null && !string.IsNullOrEmpty(Binder.Prefix)) { Prefix = Binder.Prefix; } if (Binder != null) { convert = Binder.GetConvert(); } if (convert == null) { if (ConverCore.Converts.ContainsKey(createtype)) { convert = ConverCore.Converts[createtype]; } } if (convert != null) { value = convert.Parse(data, Info.Name, Prefix, out succed); } else if (createtype.IsArray) { if (createtype.GetElementType().IsEnum) { ToEnumArray tea = new ToEnumArray(); tea.EnumType = createtype.GetElementType(); value = tea.Parse(data, Info.Name, Prefix, out succed); } } else { if (createtype.IsClass && !createtype.IsInterface && !createtype.IsAbstract) { ClassBinder cb = ConverCore.GetBinder(createtype); succed = true; value = cb.CreateObject(data, Prefix); } } return(succed); }
public bool GetClassValue(System.Collections.Specialized.NameValueCollection data, string Prefix, out object value) { IConvert convert = null; value = null; Type createtype = Handler.Property.PropertyType; if (Binder != null && Binder.Convert == null && Binder.Fungible != null) { createtype = Binder.Fungible; } bool succed = false; if (Binder != null && !string.IsNullOrEmpty(Binder.Prefix)) { Prefix = Binder.Prefix; } if (Binder != null) { convert = Binder.GetConvert(); } if (convert == null) { if (ConverCore.Converts.ContainsKey(createtype)) { convert = ConverCore.Converts[createtype]; } } if (convert != null) { value = convert.Parse(data, Handler.Property.Name, Prefix, out succed); } else { if (createtype.IsClass && !createtype.IsInterface && !createtype.IsAbstract) { if (createtype.IsArray) { succed = true; value = Activator.CreateInstance(createtype, 0); } else { ClassBinder cb = ConverCore.GetBinder(createtype); succed = true; value = cb.CreateObject(data, Prefix); } } } return(succed); }
public static object CreateInstance(Type type, NameValueCollection data, string prefix) { if (ConverCore.Converts.ContainsKey(type)) { IConvert convert = ConverCore.Converts[type]; bool succed; return(convert.Parse(data, null, prefix, out succed)); } ClassBinder cb = ConverCore.GetBinder(type); return(cb.CreateObject(data, prefix)); }
private bool GetValueTypeValue(System.Collections.Specialized.NameValueCollection data, string Prefix, out object value) { IConvert convert = null; value = null; Type createtype = Info.ParameterType; if (Binder != null && Binder.Convert == null && Binder.Fungible != null) { createtype = Binder.Fungible; } bool succed = false; if (Binder != null && !string.IsNullOrEmpty(Binder.Prefix)) { Prefix = Binder.Prefix; } if (Binder != null) { convert = Binder.GetConvert(); } if (convert == null) { if (ConverCore.Converts.ContainsKey(createtype)) { convert = ConverCore.Converts[createtype]; } } if (convert != null) { value = convert.Parse(data, Info.Name, Prefix, out succed); } else { if (createtype.IsEnum) { string pvalue = (string)new ToEnum().Parse(data, Info.Name, Prefix, out succed); if (string.IsNullOrEmpty(pvalue)) { value = Enum.GetValues(createtype).GetValue(0); } else { value = Enum.Parse(createtype, pvalue); } } } return(succed); }
internal static object CreateInstance(Type type, NameValueCollection data, string prefix) { object result; if (BindUtils.Converts.ContainsKey(type)) { IConvert convert = BindUtils.Converts[type]; bool flag; result = convert.Parse(data, null, prefix, out flag); } else { ClassBinder binder = BindUtils.GetBinder(type); result = binder.CreateObject(data, prefix); } return(result); }