예제 #1
0
        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"));
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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("&#32;", " ");
                    }
                    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;
            }
        }