SuperMap.Web.iServerJava2.ThemeUnique.ToJson C# (CSharp) Method

ToJson() static private method

static private ToJson ( ThemeUnique themeUnique ) : string
themeUnique ThemeUnique
return string
        internal static string ToJson(ThemeUnique themeUnique)
        {
            if (themeUnique == null)
            {
                return null;
            }
            string json = "{";

            List<string> list = new List<string>();

            if (themeUnique.Items != null && themeUnique.Items.Count > 0)
            {
                List<string> tempTUI = new List<string>();
                foreach (ThemeUniqueItem item in themeUnique.Items)
                {
                    tempTUI.Add(ThemeUniqueItem.ToJson(item));
                }
                list.Add(string.Format("\"items\":[{0}]", string.Join(",", tempTUI.ToArray())));
            }
            else
            {
                list.Add(string.Format("\"items\":[]"));
            }

            if (!string.IsNullOrEmpty(themeUnique.UniqueExpression))
            {
                list.Add(string.Format("\"uniqueExpression\":\"{0}\"", themeUnique.UniqueExpression));
            }
            else
            {
                list.Add(string.Format("\"uniqueExpression\":null"));
            }

            if (themeUnique.DefaultStyle != null)
            {
                list.Add(string.Format("\"defaultStyle\":{0}", ServerStyle.ToJson(themeUnique.DefaultStyle)));
            }
            else
            {
                list.Add(string.Format("\"defaultStyle\":null"));
            }

            list.Add(string.Format("\"themeType\":1"));

            if (themeUnique.MakeDefaultParam != null)
            {
                list.Add(string.Format("\"makeDefaultParam\":{0}", ThemeUniqueParam.ToJson(themeUnique.MakeDefaultParam)));
            }

            json += string.Join(",", list.ToArray());
            json += "}";

            return json;
        }