static QuerySettings() { FormatRules = new List <FormatterRule> { new FormatterRule("object", c => true, c => new CellFormatter((h, o) => { return(o != null ? o.ToString().EncodeHtml() : MvcHtmlString.Empty); }) { WriteData = false }), new FormatterRule("Enum", c => c.Type.UnNullify().IsEnum, c => new CellFormatter((h, o) => { return(o != null ? ((Enum)o).NiceToString().EncodeHtml() : MvcHtmlString.Empty); })), new FormatterRule("Lite", c => c.Type.UnNullify().IsLite(), c => new CellFormatter((h, o) => { return(h.LightEntityLine((Lite <IEntity>)o, isSearch: false)); })), new FormatterRule("Guid", c => c.Type.UnNullify() == typeof(Guid), c => new CellFormatter((h, o) => { return(o != null ? (new HtmlTag("span").Class("guid").SetInnerText(o.ToString().Start(5) + "…" + o.ToString().End(5))) : MvcHtmlString.Empty); }) { WriteData = true, TextAlign = "middle" }), new FormatterRule("DateTime", c => c.Type.UnNullify() == typeof(DateTime), c => new CellFormatter((h, o) => { return(o != null ? ((DateTime)o).ToUserInterface().ToString(c.Format).EncodeHtml() : MvcHtmlString.Empty); }) { WriteData = false, TextAlign = "right" }), new FormatterRule("TimeSpan", c => c.Type.UnNullify() == typeof(TimeSpan), c => new CellFormatter((h, o) => { return(o != null ? ((TimeSpan)o).ToString(c.Format).EncodeHtml() : MvcHtmlString.Empty); }) { WriteData = false, TextAlign = "right" }), new FormatterRule("Number", c => Reflector.IsNumber(c.Type) && c.Unit == null, c => new CellFormatter((h, o) => { return(o != null? ((IFormattable)o).ToString(c.Format, CultureInfo.CurrentCulture).EncodeHtml(): MvcHtmlString.Empty); }) { WriteData = false, TextAlign = "right" }), new FormatterRule("Number with Unit", c => Reflector.IsNumber(c.Type) && c.Unit.HasText(), c => new CellFormatter((h, o) => { if (o != null) { string s = ((IFormattable)o).ToString(c.Format, CultureInfo.CurrentCulture); if (c.Unit.HasText()) { s += " " + c.Unit; } return(s.EncodeHtml()); } return(MvcHtmlString.Empty); }) { TextAlign = "right" }), new FormatterRule("bool", c => c.Type.UnNullify() == typeof(bool), c => new CellFormatter((h, o) => { return(o != null ? new HtmlTag("input") .Attr("type", "checkbox") .Attr("disabled", "disabled") .Let(a => (bool)o ? a.Attr("checked", "checked") : a) .ToHtml() : MvcHtmlString.Empty); }) { TextAlign = "center" }), }; EntityFormatRules = new List <EntityFormatterRule> { new EntityFormatterRule(row => true, (h, row) => { if (Navigator.IsNavigable(row.Entity.EntityType, null, isSearch: true)) { return(h.LightEntityLine(row.Entity, isSearch: true, innerText: EntityControlMessage.View.NiceToString())); } else { return(MvcHtmlString.Empty); } }), }; PropertyFormatters = new Dictionary <PropertyRoute, CellFormatter>(); }