Exemplo n.º 1
0
        /// <summary>
        /// Parse a section from the JSON data.
        /// </summary>
        internal static IntermediateSection Deserialize(ISymbolDefinitionCreator creator, Uri baseUri, JsonObject jsonObject)
        {
            var id   = jsonObject.GetValueOrDefault <string>("id");
            var type = jsonObject.GetEnumOrDefault("type", SectionType.Unknown);

            if (SectionType.Unknown == type)
            {
                throw new ArgumentException("JSON object is not a valid section, unknown section type", nameof(type));
            }

            var section = new IntermediateSection(id, type);

            var symbolsJson = jsonObject.GetValueOrDefault <JsonArray>("symbols");

            foreach (JsonObject symbolJson in symbolsJson)
            {
                var symbol = IntermediateSymbol.Deserialize(creator, baseUri, symbolJson);
                section.symbols.Add(symbol);
            }

            return(section);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Removes a symbol from the section.
 /// </summary>
 /// <param name="symbol">Symbol to remove.</param>
 /// <returns>True if the symbol was removed; otherwise false.</returns>
 public bool RemoveSymbol(IntermediateSymbol symbol)
 {
     return(this.symbols.Remove(symbol));
 }