예제 #1
0
 private static string GetValue(PropertyInfo property, PersonTableViewModel item)
 {
     return(WebUtility.HtmlEncode(item.GetType()
                                  .GetProperty(property.Name)
                                  .GetValue(item)?.ToString())
            ?? string.Empty);
 }
예제 #2
0
        public static IEnumerable <string> BuildDataTableHeader(PersonTableViewModel tableViewModel)
        {
            var headerString = new List <string>();

            // Get the properties which should appear in the DataTable
            var properties = GetProperties(tableViewModel);

            foreach (var property in properties)
            {
                var listProperties = WebUtility.HtmlEncode(tableViewModel.GetType()
                                                           .GetProperty(property.Name)
                                                           .GetCustomAttributes(false)
                                                           .OfType <ShowOnDataTable>().First().ColumnName
                                                           ?? property.Name);

                // VanityId must *always* be the last property
                //listProperties.Add(item.VanityId.ToString());

                headerString.Add(listProperties);
            }

            return(headerString);
        }
예제 #3
0
 private static IOrderedEnumerable <PropertyInfo> GetProperties(PersonTableViewModel item)
 {
     return(item.GetType().GetProperties()
            .Where(p => Attribute.IsDefined(p, typeof(ShowOnDataTable)))
            .OrderBy(o => o.GetCustomAttributes(false).OfType <ShowOnDataTable>().First().Order));
 }