Ejemplo n.º 1
0
        internal static IntermediateField Deserialize(IntermediateFieldDefinition definition, Uri baseUri, JsonObject jsonObject)
        {
            var field = new IntermediateField(definition);

            if (jsonObject != null)
            {
                field.Value = IntermediateFieldValue.Deserialize(jsonObject, baseUri, definition.Type);
            }

            return(field);
        }
Ejemplo n.º 2
0
        internal static IntermediateTupleDefinition Deserialize(JsonObject jsonObject)
        {
            var name            = jsonObject.GetValueOrDefault <string>("name");
            var revision        = jsonObject.GetValueOrDefault("rev", 0);
            var definitionsJson = jsonObject.GetValueOrDefault <JsonArray>("fields");

            var fieldDefinitions = new IntermediateFieldDefinition[definitionsJson.Count];

            for (var i = 0; i < definitionsJson.Count; ++i)
            {
                var definitionJson = (JsonObject)definitionsJson[i];
                var fieldName      = definitionJson.GetValueOrDefault <string>("name");
                var fieldType      = definitionJson.GetEnumOrDefault("type", IntermediateFieldType.String);
                fieldDefinitions[i] = new IntermediateFieldDefinition(fieldName, fieldType);
            }

            return(new IntermediateTupleDefinition(name, revision, fieldDefinitions, null));
        }
        internal static IntermediateSymbolDefinition Deserialize(JsonObject jsonObject)
        {
            var name = jsonObject.GetValueOrDefault<string>("name");
            var revision = jsonObject.GetValueOrDefault("rev", 0);
            var definitionsJson = jsonObject.GetValueOrDefault<JsonArray>("fields");
            var tagsJson = jsonObject.GetValueOrDefault<JsonArray>("tags");

            var fieldDefinitions = new IntermediateFieldDefinition[definitionsJson.Count];

            for (var i = 0; i < definitionsJson.Count; ++i)
            {
                var definitionJson = (JsonObject)definitionsJson[i];
                var fieldName = definitionJson.GetValueOrDefault<string>("name");
                var fieldType = definitionJson.GetEnumOrDefault("type", IntermediateFieldType.String);
                fieldDefinitions[i] = new IntermediateFieldDefinition(fieldName, fieldType);
            }

            var definition = new IntermediateSymbolDefinition(name, revision, fieldDefinitions, null);

            if (tagsJson == null || tagsJson.Count == 0)
            {
            }
            else if (tagsJson.Count == 1)
            {
                definition.tags = (string)tagsJson[0];
            }
            else
            {
                var tags = new string[tagsJson.Count];

                for (var i = 0; i < tagsJson.Count; ++i)
                {
                    tags[i] = (string)tagsJson[i];
                }

                definition.tags = tags;
            }

            return definition;
        }
Ejemplo n.º 4
0
 public IntermediateField(IntermediateFieldDefinition definition)
 {
     this.Definition = definition;
 }
Ejemplo n.º 5
0
 private static IntermediateField EnsureField(IntermediateField field, IntermediateFieldDefinition definition)
 {
     return(field ?? new IntermediateField(definition));
 }
Ejemplo n.º 6
0
 public static IntermediateField Set(this IntermediateField field, IntermediateFieldDefinition definition, string value)
 {
     return(EnsureField(field, definition).Set(value));
 }