Esempio n. 1
0
 public override void Write(Utf8JsonWriter writer, NamedArgument value, JsonSerializerOptions options)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("type");
     writer.WriteStringValue("NamedArgument");
     writer.WritePropertyName("name");
     JsonSerializer.Serialize(writer, value.Name, options);
     writer.WritePropertyName("value");
     ResourceSerializer.WriteInlineExpression(writer, value.Value, options);
     writer.WriteEndObject();
 }
 public override void Write(Utf8JsonWriter writer, SelectExpression value, JsonSerializerOptions options)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("type");
     writer.WriteStringValue("SelectExpression");
     writer.WritePropertyName("selector");
     ResourceSerializer.WriteInlineExpression(writer, value.Selector, options);
     writer.WritePropertyName("variants");
     writer.WriteStartArray();
     foreach (var variant in value.Variants)
     {
         JsonSerializer.Serialize(writer, variant, options);
     }
     writer.WriteEndArray();
     writer.WriteEndObject();
 }
Esempio n. 3
0
        public override void Write(Utf8JsonWriter writer, Placeable value, JsonSerializerOptions options)
        {
            writer.WriteStartObject();
            writer.WritePropertyName("type");
            writer.WriteStringValue("Placeable");
            writer.WritePropertyName("expression");

            switch (value.Expression)
            {
            case IInlineExpression inlineExpression:
                ResourceSerializer.WriteInlineExpression(writer, inlineExpression, options);
                break;

            case SelectExpression selectExpression:
                JsonSerializer.Serialize(writer, selectExpression, options);
                break;
            }

            writer.WriteEndObject();
        }
Esempio n. 4
0
 public override void Write(Utf8JsonWriter writer, CallArguments value, JsonSerializerOptions options)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("type");
     writer.WriteStringValue("CallArguments");
     writer.WritePropertyName("positional");
     writer.WriteStartArray();
     foreach (var positionalArg in value.PositionalArgs)
     {
         ResourceSerializer.WriteInlineExpression(writer, positionalArg, options);
     }
     writer.WriteEndArray();
     writer.WritePropertyName("named");
     writer.WriteStartArray();
     foreach (var namedArg in value.NamedArgs)
     {
         JsonSerializer.Serialize(writer, namedArg, options);
     }
     writer.WriteEndArray();
     writer.WriteEndObject();
 }