| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | using System;using System.Collections.Generic;using System.Linq;using System.Linq.Expressions;using InABox.Configuration;using InABox.Core;namespace InABox.DynamicGrid{    public class DynamicGridColumns : List<DynamicGridColumn>, IGlobalConfigurationSettings, IUserConfigurationSettings    {        public string GridName { get; set; }        private static Dictionary<Type, List<DynamicGridColumn>> _columnscache = new Dictionary<Type, List<DynamicGridColumn>>();        public DynamicGridColumns ExtractColumns(Type type)        {            if (!_columnscache.ContainsKey(type))            {                _columnscache[type] = new List<DynamicGridColumn>();                var properties = DatabaseSchema.Properties(type).OrderBy(x => x.Sequence);                foreach (var prop in properties)                {                    if ((prop.Editor != null && !(prop.Editor is NullEditor)) || prop.Required)                    {                        var col = new DynamicGridColumn                        {                            ColumnName = prop.Name,                            Width = prop.Editor.Width,                            Alignment = prop.Editor.Alignment,                            Format = prop.Editor.Format,                            Editor = prop.Editor,                            Caption = prop.Caption                        };                        _columnscache[type].Add(col);                    }                }            }            AddRange(_columnscache[type]);            return this;        }        public DynamicGridColumn Add<TType, TProperty>(Expression<Func<TType, TProperty>> member, int width, string caption, string format,            Alignment alignment)        {            var name = CoreUtils.GetFullPropertyName(member, ".");            var result = new DynamicGridColumn            {                ColumnName = name,                Caption = caption,                Width = width,                Format = format,                Alignment = alignment            };            Add(result);            return result;        }    }}
 |