Exemplo n.º 1
0
        public object Parse(System.Collections.Specialized.NameValueCollection data, string key, string prefix, out bool succeed)
        {
            IList <T> items = null;

            succeed = true;
            System.Type itemstype = System.Type.GetType("System.Collections.Generic.List`1");
            itemstype = itemstype.MakeGenericType(typeof(T));
            items     = (IList <T>)Activator.CreateInstance(itemstype);
            int count = 0;

            string[] values;
            Dictionary <System.Reflection.PropertyInfo, string[]> valueCollection = new Dictionary <System.Reflection.PropertyInfo, string[]>();

            foreach (System.Reflection.PropertyInfo pi in Properties)
            {
                values = ConverCore.GetValues(data, pi.Name, prefix);
                if (values != null && values.Length > count)
                {
                    count = values.Length;
                }
                valueCollection.Add(pi, values);
            }

            for (int i = 0; i < count; i++)
            {
                System.Collections.Specialized.NameValueCollection itemdata = new System.Collections.Specialized.NameValueCollection();
                foreach (System.Reflection.PropertyInfo pi in Properties)
                {
                    values = valueCollection[pi];
                    if (values != null && i < values.Length)
                    {
                        itemdata.Add(pi.Name, values[i]);
                    }
                }
                T item = BinderAdapter.CreateInstance <T>(itemdata);
                items.Add(item);
            }
            return(items);
        }
Exemplo n.º 2
0
 public void FullValue(object source, System.Collections.Specialized.NameValueCollection data, string Prefix, bool ispostback)
 {
     BinderAdapter.Full(source, data, Prefix, ispostback);
 }