public object Parse(NameValueCollection data, string key, string prefix, out bool succeed) { string value = BindUtils.GetValue(data, key, prefix); object result; if (string.IsNullOrEmpty(value)) { succeed = true; result = default(T); } else { IEnumValue enumConvert = BindUtils.GetEnumConvert(typeof(T)); result = enumConvert.GetValue(value, out succeed); } return(result); }
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); }
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 (BindUtils.Converts.ContainsKey(createtype)) { convert = BindUtils.Converts[createtype]; } } if (convert != null) { value = convert.Parse(data, Info.Name, Prefix, out succed); } else { if (createtype.IsEnum) { string pvalue = BindUtils.GetValue(data, Info.Name, Prefix); IEnumValue evalue = BindUtils.GetEnumConvert(createtype); value = evalue.GetValue(pvalue, out succed); } } return(succed); }