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

ToJson() static private method

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

            list.Add(string.Format("\"barWidth\":{0}", themeGraph.BarWidth.ToString(System.Globalization.CultureInfo.InvariantCulture)));

            if (themeGraph.Flow != null)
            {
                list.Add(ThemeFlow.ToJson(themeGraph.Flow));
            }
            else
            {
                list.Add(string.Format("\"leaderLineStyle\":{0}", ServerStyle.ToJson(new ServerStyle())));
                list.Add("\"flowEnabled\":true");
                list.Add("\"leaderLineDisplayed\":false");
            }

            list.Add(string.Format("\"graduatedMode\":\"{0}\"", themeGraph.GraduatedMode));

            if (themeGraph.GraphAxes != null)
            {
                list.Add(ThemeGraphAxes.ToJson(themeGraph.GraphAxes));
            }
            else
            {
                list.Add(string.Format("\"axesColor\":{0}", ServerColor.ToJson(new ServerColor())));
                list.Add("\"axesDisplayed\":false");
                list.Add("\"axesGridDisplayed\":false");
                list.Add(string.Format("\"axesTextStyle\":{0}", ServerTextStyle.ToJson(new ServerTextStyle())));
                list.Add("\"axesTextDisplayed\":false");
            }

            if (themeGraph.GraphSize != null)
            {
                list.Add(ThemeGraphSize.ToJson(themeGraph.GraphSize));
            }
            else
            {
                list.Add(string.Format("\"maxGraphSize\":0.0"));
                list.Add(string.Format("\"minGraphSize\":0.0"));
            }

            list.Add(string.Format("\"graphSizeFixed\":{0}", themeGraph.GraphSizeFixed.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLower()));

            if (themeGraph.GraphText != null)
            {
                list.Add(ThemeGraphText.ToJson(themeGraph.GraphText));
            }
            else
            {
                list.Add(string.Format("\"graphTextStyle\":{0}", ServerTextStyle.ToJson(new ServerTextStyle())));
                list.Add("\"graphTextDisplayed\":false");
                list.Add("\"graphTextFormat\":\"CAPTION\"");
            }

            list.Add(string.Format("\"graphType\":\"{0}\"", themeGraph.GraphType));

            if (themeGraph.Items != null && themeGraph.Items.Count > 0)
            {
                List<string> itemList = new List<string>();
                foreach (var item in themeGraph.Items)
                {
                    itemList.Add(ThemeGraphItem.ToJson(item));

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

            list.Add(string.Format("\"negativeDisplayed\":{0}", themeGraph.NegativeDisplayed.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLower()));

            if (themeGraph.Offset != null)
            {
                list.Add(ThemeOffset.ToJson(themeGraph.Offset));
            }
            else
            {
                list.Add("\"offsetX\":\"\"");
                list.Add("\"offsetY\":\"\"");
                list.Add("\"offsetFixed\":false");
            }

            list.Add(string.Format("\"overlapAvoided\":{0}", themeGraph.OverlapAvoided.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLower()));

            list.Add(string.Format("\"roseAngle\":{0}", themeGraph.RoseAngle.ToString(System.Globalization.CultureInfo.InvariantCulture)));
            list.Add(string.Format("\"startAngle\":{0}", themeGraph.StartAngle.ToString(System.Globalization.CultureInfo.InvariantCulture)));

            list.Add("\"memoryData\":null");
            list.Add("\"type\":\"GRAPH\"");

            if (themeGraph.MemoryKeys != null && themeGraph.MemoryKeys.Count > 0)
            {
                list.Add(string.Format("\"memoryKeys\":[{0}]", string.Join(",", themeGraph.MemoryKeys)));
            }
            else
            {
                list.Add("\"memoryKeys\":[]");
            }

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

            return json;
        }