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); }
public static IEnumerable <string> ToKeys(object value) { if (value != null) { return(PropertyHelper.GetProperties(value).Select(helper => helper.Name)); } return(new string[] { }); }
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); }
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); }