public void ImplementAnyMethod() { var attributes = new HtmlAttributes(new { }); Assert.IsFalse(attributes.Any()); attributes["test"] = "test"; Assert.IsTrue(attributes.Any()); Assert.IsFalse(attributes.Any(x => x.Key == "fail")); }
protected override void Serialize(IDictionary <string, object> json) { if (Title.HasValue()) { json["title"] = Title; } if (HtmlAttributes.Any()) { var attributes = new Dictionary <string, object>(); HtmlAttributes.Each(attr => { attributes[HttpUtility.HtmlAttributeEncode(attr.Key)] = HttpUtility.HtmlAttributeEncode(attr.Value.ToString()); }); json["attributes"] = attributes; } if (FooterHtmlAttributes.Any()) { var attributes = new Dictionary <string, object>(); FooterHtmlAttributes.Each(attr => { attributes[HttpUtility.HtmlAttributeEncode(attr.Key)] = HttpUtility.HtmlAttributeEncode(attr.Value.ToString()); }); json["footerAttributes"] = attributes; } if (Hidden) { json["hidden"] = true; } if (!IncludeInMenu) { json["menu"] = false; } if (Width.HasValue()) { json["width"] = Width; } if (ClientTemplate.HasValue()) { json["template"] = HttpUtility.UrlDecode(ClientTemplate); } if (ClientFooterTemplate.HasValue()) { json["footerTemplate"] = HttpUtility.UrlDecode(ClientFooterTemplate); } if (!Encoded) { json["encoded"] = Encoded; } }
public virtual IDictionary <string, object> Serialize(IGridUrlBuilder urlBuilder) { var command = new Dictionary <string, object>(); FluentDictionary.For(command) .Add("name", Name) .Add("attr", HtmlAttributes.ToAttributeString(), () => HtmlAttributes.Any()) .Add("buttonType", ButtonType.ToString()) .Add("imageAttr", ImageHtmlAttributes.ToAttributeString(), () => ImageHtmlAttributes.Any()); return(command); }
protected override void Serialize(IDictionary <string, object> json) { if (Title.HasValue()) { json["title"] = Title; } if (HtmlAttributes.Any()) { var attributes = new Dictionary <string, object>(); var hasAntiXss = HttpEncoder.Current != null && HttpEncoder.Current.GetType().ToString().Contains("AntiXssEncoder"); HtmlAttributes.Each(attr => { var value = HttpUtility.HtmlAttributeEncode(attr.Value.ToString()); if (hasAntiXss) { value = value.Replace(" ", " "); } attributes[HttpUtility.HtmlAttributeEncode(attr.Key)] = value; }); json["attributes"] = attributes; } if (FooterHtmlAttributes.Any()) { var attributes = new Dictionary <string, object>(); FooterHtmlAttributes.Each(attr => { attributes[HttpUtility.HtmlAttributeEncode(attr.Key)] = HttpUtility.HtmlAttributeEncode(attr.Value.ToString()); }); json["footerAttributes"] = attributes; } if (Hidden) { json["hidden"] = true; } if (!IncludeInMenu) { json["menu"] = false; } if (Width.HasValue()) { json["width"] = Width; } if (ClientTemplate.HasValue()) { json["template"] = HttpUtility.UrlDecode(ClientTemplate); } if (ClientFooterTemplate.HasValue()) { json["footerTemplate"] = HttpUtility.UrlDecode(ClientFooterTemplate); } if (!Encoded) { json["encoded"] = Encoded; } }