Esempio n. 1
0
 public override JsonNode this[int aIndex]
 {
     get
     {
         if (aIndex < 0 || aIndex >= m_List.Count)
         {
             return(new JsonLazyCreator(this));
         }
         return(m_List[aIndex]);
     }
     set
     {
         if (value == null)
         {
             value = JsonNull.CreateOrGet();
         }
         if (aIndex < 0 || aIndex >= m_List.Count)
         {
             m_List.Add(value);
         }
         else
         {
             m_List[aIndex] = value;
         }
     }
 }
Esempio n. 2
0
        private static JsonNode ParseElement(string token, bool quoted)
        {
            if (quoted)
            {
                return(token);
            }
            string tmp = token.ToLower();

            if (tmp == "false" || tmp == "true")
            {
                return(tmp == "true");
            }
            if (tmp == "null")
            {
                return(JsonNull.CreateOrGet());
            }
            double val;

            if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out val))
            {
                return(val);
            }
            else
            {
                return(token);
            }
        }
Esempio n. 3
0
 public override JsonNode this[string aKey]
 {
     get
     {
         if (m_Dict.ContainsKey(aKey))
         {
             return(m_Dict[aKey]);
         }
         else
         {
             return(new JsonLazyCreator(this, aKey));
         }
     }
     set
     {
         if (value == null)
         {
             value = JsonNull.CreateOrGet();
         }
         if (m_Dict.ContainsKey(aKey))
         {
             m_Dict[aKey] = value;
         }
         else
         {
             m_Dict.Add(aKey, value);
         }
     }
 }
Esempio n. 4
0
 public override void Add(string aKey, JsonNode aItem)
 {
     if (aItem == null)
     {
         aItem = JsonNull.CreateOrGet();
     }
     m_List.Add(aItem);
 }
Esempio n. 5
0
 public override JsonNode this[string aKey]
 {
     get { return(new JsonLazyCreator(this)); }
     set
     {
         if (value == null)
         {
             value = JsonNull.CreateOrGet();
         }
         m_List.Add(value);
     }
 }
Esempio n. 6
0
        public override void Add(string aKey, JsonNode aItem)
        {
            if (aItem == null)
            {
                aItem = JsonNull.CreateOrGet();
            }

            if (!string.IsNullOrEmpty(aKey))
            {
                if (m_Dict.ContainsKey(aKey))
                {
                    m_Dict[aKey] = aItem;
                }
                else
                {
                    m_Dict.Add(aKey, aItem);
                }
            }
            else
            {
                m_Dict.Add(Guid.NewGuid().ToString(), aItem);
            }
        }
Esempio n. 7
0
 public override JsonNode this[int aIndex]
 {
     get
     {
         if (aIndex < 0 || aIndex >= m_Dict.Count)
         {
             return(null);
         }
         return(m_Dict.ElementAt(aIndex).Value);
     }
     set
     {
         if (value == null)
         {
             value = JsonNull.CreateOrGet();
         }
         if (aIndex < 0 || aIndex >= m_Dict.Count)
         {
             return;
         }
         string key = m_Dict.ElementAt(aIndex).Key;
         m_Dict[key] = value;
     }
 }