SuperMap.WinRT.REST.ThemeGraduatedSymbol.ToJson C# (CSharp) Метод

ToJson() статический приватный Метод

static private ToJson ( ThemeGraduatedSymbol graduatedSymbolTheme ) : string
graduatedSymbolTheme ThemeGraduatedSymbol
Результат string
        internal static string ToJson(ThemeGraduatedSymbol graduatedSymbolTheme)
        {
            string json = "{";
            List<string> list = new List<string>();

            list.Add(string.Format("\"baseValue\":{0}", graduatedSymbolTheme.BaseValue.ToString()));

            if (!string.IsNullOrEmpty(graduatedSymbolTheme.Expression))
            {
                list.Add(string.Format("\"expression\":\"{0}\"", graduatedSymbolTheme.Expression));
            }
            else
            {
                list.Add("\"expression\":\"\"");
            }

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

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

            if (graduatedSymbolTheme.Style != null)
            {
                list.Add(ThemeGraduatedSymbolStyle.ToJson(graduatedSymbolTheme.Style));
            }
            else
            {
                list.Add(string.Format("\"positiveStyle\":{0}", ServerStyle.ToJson(new ServerStyle())));
                list.Add(string.Format("\"negativeStyle\":{0}", ServerStyle.ToJson(new ServerStyle())));
                list.Add(string.Format("\"zeroStyle\":{0}", ServerStyle.ToJson(new ServerStyle())));
            }

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

            if (graduatedSymbolTheme.MemoryData != null)
            {
                list.Add("\"memoryData\":" + graduatedSymbolTheme.ToJson(graduatedSymbolTheme.MemoryData));
            }
            else
            {
                list.Add("\"memoryData\":null");
            }
            list.Add("\"type\":\"GRADUATEDSYMBOL\"");

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

Usage Example

        internal static string ToJson(ThemeGraduatedSymbol graduatedSymbolTheme)
        {
            string json = "{";
            List<string> list = new List<string>();

            list.Add(string.Format("\"baseValue\":{0}", graduatedSymbolTheme.BaseValue.ToString()));

            if (!string.IsNullOrEmpty(graduatedSymbolTheme.Expression))
            {
                list.Add(string.Format("\"expression\":\"{0}\"", graduatedSymbolTheme.Expression));
            }
            else
            {
                list.Add("\"expression\":\"\"");
            }

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

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

            if (graduatedSymbolTheme.Style != null)
            {
                list.Add(ThemeGraduatedSymbolStyle.ToJson(graduatedSymbolTheme.Style));
            }
            else
            {
                list.Add(string.Format("\"positiveStyle\":{0}", ServerStyle.ToJson(new ServerStyle())));
                list.Add(string.Format("\"negativeStyle\":{0}", ServerStyle.ToJson(new ServerStyle())));
                list.Add(string.Format("\"zeroStyle\":{0}", ServerStyle.ToJson(new ServerStyle())));
            }

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

            if (graduatedSymbolTheme.MemoryData != null)
            {
                list.Add("\"memoryData\":" + graduatedSymbolTheme.ToJson(graduatedSymbolTheme.MemoryData));
            }
            else
            {
                list.Add("\"memoryData\":null");
            }
            list.Add("\"type\":\"GRADUATEDSYMBOL\"");

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