Пример #1
0
 public override JSONNode this[string aKey]
 {
     get
     {
         return((JSONNode) new JSONLazyCreator((JSONNode)this));
     }
     set
     {
         if (value == (object)null)
         {
             value = (JSONNode)JSONNull.CreateOrGet();
         }
         this.m_List.Add(value);
     }
 }
Пример #2
0
 public override void Add(string aKey, JSONNode aItem)
 {
     if (aItem == (object)null)
     {
         aItem = (JSONNode)JSONNull.CreateOrGet();
     }
     if (!string.IsNullOrEmpty(aKey))
     {
         if (this.m_Dict.ContainsKey(aKey))
         {
             this.m_Dict[aKey] = aItem;
         }
         else
         {
             this.m_Dict.Add(aKey, aItem);
         }
     }
     else
     {
         this.m_Dict.Add(Guid.NewGuid().ToString(), aItem);
     }
 }
Пример #3
0
 public override JSONNode this[int aIndex]
 {
     get
     {
         if (aIndex < 0 || aIndex >= this.m_Dict.Count)
         {
             return((JSONNode)null);
         }
         return(this.m_Dict.ElementAt <KeyValuePair <string, JSONNode> >(aIndex).Value);
     }
     set
     {
         if (value == (object)null)
         {
             value = (JSONNode)JSONNull.CreateOrGet();
         }
         if (aIndex < 0 || aIndex >= this.m_Dict.Count)
         {
             return;
         }
         this.m_Dict[this.m_Dict.ElementAt <KeyValuePair <string, JSONNode> >(aIndex).Key] = value;
     }
 }
Пример #4
0
        private static JSONNode ParseElement(string token, bool quoted)
        {
            if (quoted)
            {
                return((JSONNode)token);
            }
            string lower = token.ToLower();

            if (lower == "false" || lower == "true")
            {
                return((JSONNode)(lower == "true"));
            }
            if (lower == "null")
            {
                return((JSONNode)JSONNull.CreateOrGet());
            }
            double result;

            if (double.TryParse(token, NumberStyles.Float, (IFormatProvider)CultureInfo.InvariantCulture, out result))
            {
                return((JSONNode)result);
            }
            return((JSONNode)token);
        }