예제 #1
0
        public bool FinishArrayItem()
        {
            if (ContentTable.Count > 1)
            {
                return(Program.ReportFailure("Unexpected failure"));
            }

            Debug.Assert(ContentTypeTable.Count == ContentTable.Count);

            foreach (KeyValuePair <string, object> Entry in ContentTable)
            {
                string Key = Entry.Key;
                Debug.Assert(ContentTypeTable.ContainsKey(Key));

                if (ItemCollection.Count > 0)
                {
                    if (ContentTypeTable[Key] != LastItemType)
                    {
                        return(Program.ReportFailure("Mixed array types"));
                    }
                }

                ItemCollection.Add(Entry.Value);
                LastItemType = ContentTypeTable[Key];
            }

            ContentTable.Clear();
            ContentTypeTable.Clear();
            return(true);
        }
예제 #2
0
        public bool SetContent(string key, object?value, Json.Token jsonType)
        {
            if (ContentTable.ContainsKey(key))
            {
                return(Program.ReportFailure($"Key '{key}' already parsed for object"));
            }

            Debug.Assert(!ContentTypeTable.ContainsKey(key));

            ContentTable.Add(key, value !);
            ContentTypeTable.Add(key, jsonType);

            return(true);
        }
예제 #3
0
        public bool FinishArray(string key, ParsingContext arrayContext)
        {
            if (ContentTable.ContainsKey(key))
            {
                return(Program.ReportFailure($"Key '{key}' already parsed for object"));
            }

            Debug.Assert(!ContentTypeTable.ContainsKey(key));

            ContentTable.Add(key, arrayContext.ItemCollection);
            ContentTypeTable.Add(key, arrayContext.LastItemType);

            return(true);
        }