コード例 #1
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
        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));
        }
コード例 #2
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
        public static object GetObject(Type type, string prefix)
        {
            object obj = Activator.CreateInstance(type);

            BinderHelper.Full(obj, HttpContext.Current.Request.Params, prefix, false);
            return(obj);
        }
コード例 #3
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
 static BinderHelper()
 {
     BinderHelper.mIListConvert = new Dictionary <Type, IConvert>();
     BinderHelper.AddCustomConvert(new Assembly[]
     {
         typeof(BinderHelper).Assembly
     });
 }
コード例 #4
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
        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);
        }
コード例 #5
0
ファイル: ToIList.cs プロジェクト: isensen/Peanut
        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);
        }
コード例 #6
0
ファイル: PropertyBinder.cs プロジェクト: isensen/Peanut
 public void FullValue(object source, System.Collections.Specialized.NameValueCollection data, string Prefix, bool ispostback)
 {
     BinderHelper.Full(source, data, Prefix, ispostback);
 }
コード例 #7
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
 public static T GetObject <T>(string prefix) where T : new()
 {
     return((T)BinderHelper.GetObject(typeof(T), prefix));
 }
コード例 #8
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
 public static T GetObject <T>() where T : new()
 {
     return(BinderHelper.GetObject <T>(null));
 }
コード例 #9
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
 internal static T CreateInstance <T>(NameValueCollection data)
 {
     return(BinderHelper.CreateInstance <T>(data, null));
 }
コード例 #10
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
 internal static T CreateInstance <T>(NameValueCollection data, string prefix)
 {
     return((T)BinderHelper.CreateInstance(typeof(T), data, prefix));
 }
コード例 #11
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
 internal static object CreateInstance(Type type, NameValueCollection data)
 {
     return(BinderHelper.CreateInstance(type, data, null));
 }
コード例 #12
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
 public static IList <T> GetList <T>(NameValueCollection data, string prefix) where T : new()
 {
     return((IList <T>)BinderHelper.GetList(typeof(T), data, prefix));
 }
コード例 #13
0
ファイル: BinderHelper.cs プロジェクト: isensen/Peanut
 public static IList <T> GetList <T>() where T : new()
 {
     return(BinderHelper.GetList <T>(HttpContext.Current.Request.Params, ""));
 }