Beispiel #1
0
        public IJsonItem Parse(string json)
        {
            (IMatchData matchData, bool success, int _, int?failureIndex, string _) = _languageMatchEngine.Match(json);
            if (!success)
            {
                int line = EngineUtils.GetLineNumber(json, failureIndex.Value);
                throw new LanaguageSyntaxException($"Syntax error at line {line}: {EngineUtils.GetLine(json, line, 100).Trim()}...", failureIndex.Value);
            }
            JsonItem item = GetJsonItem(((FragmentMatchData)matchData).Parts[0]);

            item.Load(false);
            return(item);
        }
Beispiel #2
0
 public override void Load(bool eager = false)
 {
     if (!_loaded)
     {
         List <IMatchData> parts = _matchData.Parts;
         int         size        = parts.Count;
         IJsonItem[] items       = new IJsonItem[size];
         for (int i = 0; i < size; i++)
         {
             JsonItem item = GetJsonItem(parts[i]);
             if (eager)
             {
                 item.Load(eager);
             }
             items[i] = item;
         }
         _items  = items;
         _loaded = true;
     }
 }
Beispiel #3
0
 public override void Load(bool eager = false)
 {
     if (!_loaded)
     {
         List <IMatchData> parts = _matchData.Parts;
         int size = parts.Count;
         Dictionary <string, IJsonItem> items = new Dictionary <string, IJsonItem>(size);
         for (int i = 0; i < size; i++)
         {
             FragmentMatchData keyValue = (FragmentMatchData)parts[i];
             JsonItem          item     = GetJsonItem(keyValue.Parts[1]);
             if (eager)
             {
                 item.Load(eager);
             }
             items[GetStringText(GetStringMatchDataText((StringMatchData)keyValue.Parts[0]))] = item;
         }
         _items  = items;
         _loaded = true;
     }
 }