SuperMap.Web.iServerJava6R.ThemeGridUnique.ToJson C# (CSharp) Method

ToJson() static private method

static private ToJson ( ThemeGridUnique themeGridUnique ) : string
themeGridUnique ThemeGridUnique
return string
        internal static string ToJson(ThemeGridUnique themeGridUnique)
        {
            string json = "{";
            List<string> list = new List<string>();

            if (themeGridUnique.Items != null && themeGridUnique.Items.Count >= 1)
            {
                List<string> tempTUI = new List<string>();
                foreach (var item in themeGridUnique.Items)
                {
                    tempTUI.Add(ThemeGridUniqueItem.ToJson(item));
                }

                list.Add(string.Format("\"items\":[{0}]", String.Join(",", tempTUI.ToArray())));
            }
            else
            {
                list.Add("\"items\":[]");
            }

            if (themeGridUnique.DefaultColor != null)
            {
                list.Add(string.Format("\"defaultColor\":{0}", ServerColor.ToJson(themeGridUnique.DefaultColor)));
            }
            else
            {
                list.Add(string.Format("\"defaultColor\":{0}", ServerColor.ToJson(new ServerColor())));
            }

            list.Add("\"type\":\"GRIDUNIQUE\"");

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

            return json;
        }