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

            if (null == id && (SectionType.Unknown != type && SectionType.Fragment != type))
            {
                throw new ArgumentException("JSON object is not a valid section");
            }

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

            var section = new IntermediateSection(id, type, codepage);

            var tuplesJson = jsonObject.GetValueOrDefault <JsonArray>("tuples");

            foreach (JsonObject tupleJson in tuplesJson)
            {
                var tuple = IntermediateTuple.Deserialize(creator, baseUri, tupleJson);
                section.Tuples.Add(tuple);
            }

            return(section);
        }
Example #2
0
File: Symbol.cs Project: 2dave/Data
 /// <summary>
 /// Creates a symbol for a row.
 /// </summary>
 /// <param name="row">Row for the symbol</param>
 public Symbol(IntermediateSection section, IntermediateTuple tuple)
 {
     this.Row     = tuple;
     this.Section = section;
     this.Name    = String.Concat(this.Row.Definition.Name, ":", this.Row.Id.Id);
 }