Ejemplo n.º 1
0
        public CodegenExpression CodegenSerialize(
            JsonSerializerForgeRefs refs,
            CodegenMethod method,
            CodegenClassScope classScope)
        {
            // We need to encode the _subForge into a lambda of its own
            var itemSerializer = new CodegenExpressionLambda(method.Block)
                                 .WithBody(block => _subForge.CodegenSerialize(refs, method, classScope));

            return(StaticMethod(
                       typeof(JsonSerializerUtil),
                       "WriteJsonList",
                       refs.Context,
                       refs.Field,
                       itemSerializer));
        }
Ejemplo n.º 2
0
        public CodegenExpression CodegenSerialize(
            JsonSerializerForgeRefs refs,
            CodegenMethod method,
            CodegenClassScope classScope)
        {
            var subRefs = new JsonSerializerForgeRefs(
                Ref("_context"),
                Ref("_arrayItem"),
                Ref("_name"));

            var serializationExpr = _subForge.CodegenSerialize(subRefs, method, classScope);
            var itemSerializer    = new CodegenExpressionLambda(method.Block)
                                    .WithParam(typeof(JsonSerializationContext), "_context")
                                    .WithParam(_componentType, "_arrayItem")
                                    .WithBody(block => block.Expression(serializationExpr));

            return(StaticMethod(
                       typeof(JsonSerializerUtil),
                       "WriteNestedArray",
                       refs.Context,
                       refs.Field,
                       itemSerializer));
        }
Ejemplo n.º 3
0
        public CodegenExpression CodegenSerialize(
            JsonSerializerForgeRefs refs,
            CodegenMethod method,
            CodegenClassScope classScope)
        {
            var subRefs = new JsonSerializerForgeRefs(
                Ref("_context"),
                Ref("_value"),
                Ref("_name"));

            var serializationExpr = _valueForge.CodegenSerialize(subRefs, method, classScope);
            var itemSerializer    = new CodegenExpressionLambda(method.Block)
                                    .WithParam(typeof(JsonSerializationContext), "_context")
                                    .WithParam(_valueType, "_value")
                                    .WithBody(block => block.Expression(serializationExpr));

            return(StaticMethod(
                       typeof(JsonSerializerUtil),
                       "WriteJsonMap",
                       new [] { _valueType },
                       refs.Context,
                       refs.Field,
                       itemSerializer));
        }