Exemple #1
0
        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));
        }
Exemple #2
0
        public static object GetObject(Type type, string prefix)
        {
            object obj = Activator.CreateInstance(type);

            BinderHelper.Full(obj, HttpContext.Current.Request.Params, prefix, false);
            return(obj);
        }
Exemple #3
0
 static BinderHelper()
 {
     BinderHelper.mIListConvert = new Dictionary <Type, IConvert>();
     BinderHelper.AddCustomConvert(new Assembly[]
     {
         typeof(BinderHelper).Assembly
     });
 }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
 public void FullValue(object source, System.Collections.Specialized.NameValueCollection data, string Prefix, bool ispostback)
 {
     BinderHelper.Full(source, data, Prefix, ispostback);
 }
Exemple #7
0
 public static T GetObject <T>(string prefix) where T : new()
 {
     return((T)BinderHelper.GetObject(typeof(T), prefix));
 }
Exemple #8
0
 public static T GetObject <T>() where T : new()
 {
     return(BinderHelper.GetObject <T>(null));
 }
Exemple #9
0
 internal static T CreateInstance <T>(NameValueCollection data)
 {
     return(BinderHelper.CreateInstance <T>(data, null));
 }
Exemple #10
0
 internal static T CreateInstance <T>(NameValueCollection data, string prefix)
 {
     return((T)BinderHelper.CreateInstance(typeof(T), data, prefix));
 }
Exemple #11
0
 internal static object CreateInstance(Type type, NameValueCollection data)
 {
     return(BinderHelper.CreateInstance(type, data, null));
 }
Exemple #12
0
 public static IList <T> GetList <T>(NameValueCollection data, string prefix) where T : new()
 {
     return((IList <T>)BinderHelper.GetList(typeof(T), data, prefix));
 }
Exemple #13
0
 public static IList <T> GetList <T>() where T : new()
 {
     return(BinderHelper.GetList <T>(HttpContext.Current.Request.Params, ""));
 }