示例#1
0
        public override string GenerateJson(bool topLevel)
        {
            var b = new StringBuilder(base.GenerateJson(false));

            var s = Text1.GenerateJson(false);

            if (!string.IsNullOrWhiteSpace(s) && s != "\"\"")
            {
                b.AppendFormat(s.StartsWith("\"") ? "Text1:{0}," : "Text1:\"{0}\",", s);
            }

            s = Text2.GenerateJson(false);
            if (!string.IsNullOrWhiteSpace(s) && s != "\"\"")
            {
                b.AppendFormat(s.StartsWith("\"") ? "Text2:{0}," : "Text2:\"{0}\",", s);
            }

            s = Text3.GenerateJson(false);
            if (!string.IsNullOrWhiteSpace(s) && s != "\"\"")
            {
                b.AppendFormat(s.StartsWith("\"") ? "Text3:{0}," : "Text3:\"{0}\",", s);
            }

            s = Text4.GenerateJson(false);
            if (!string.IsNullOrWhiteSpace(s) && s != "\"\"")
            {
                b.AppendFormat(s.StartsWith("\"") ? "Text4:{0}," : "Text4:\"{0}\",", s);
            }

            return(b.ToString());
        }