Esempio n. 1
0
        private static DataRow NewRow <T>(DataTable table, T item)
        {
            var row = table.NewRow();

            PropertyHelper.GetProperties(item).Each(helper => row[helper.Name] = helper.GetValue(item));

            return(row);
        }
Esempio n. 2
0
        public static IEnumerable <string> ToKeys(object value)
        {
            if (value != null)
            {
                return(PropertyHelper.GetProperties(value).Select(helper => helper.Name));
            }

            return(new string[] { });
        }
Esempio n. 3
0
        public static IDictionary <string, object> ToPairs(object value)
        {
            var pairs = new Dictionary <string, object>();

            if (value != null)
            {
                PropertyHelper.GetProperties(value).Each(helper => pairs.Add(helper.Name, helper.GetValue(value)));
            }

            return(pairs);
        }
Esempio n. 4
0
        public static RouteValueDictionary ObjectToDictionaryUncached(object value)
        {
            RouteValueDictionary dictionary = new RouteValueDictionary();

            if (value != null)
            {
                foreach (PropertyHelper helper in PropertyHelper.GetProperties(value))
                {
                    dictionary.Add(helper.Name, helper.GetValue(value));
                }
            }
            return(dictionary);
        }