Пример #1
0
 public CodegenExpression CodegenSerialize(
     JsonSerializerForgeRefs refs,
     CodegenMethod method,
     CodegenClassScope classScope)
 {
     return(StaticMethod(typeof(JsonSerializerUtil), "WriteNullableStringToString", refs.Context, refs.Field));
 }
Пример #2
0
 public CodegenExpression CodegenSerialize(
     JsonSerializerForgeRefs refs,
     CodegenMethod method,
     CodegenClassScope classScope)
 {
     return(ExprDotMethod(refs.Context, "WriteNullValue"));
 }
Пример #3
0
 public CodegenExpression CodegenSerialize(
     JsonSerializerForgeRefs refs,
     CodegenMethod method,
     CodegenClassScope classScope)
 {
     return(ExprDotMethod(NewInstance(adapterClass), "Write", refs.Field, refs.Context));
 }
Пример #4
0
 public CodegenExpression CodegenSerialize(JsonSerializerForgeRefs refs, CodegenMethod method, CodegenClassScope classScope)
 {
     if (methodName.Equals("WriteJsonValue") || methodName.Equals("WriteJsonArray"))
     {
         return(StaticMethod(typeof(JsonSerializerUtil), methodName, refs.Context, refs.Name, refs.Field));
     }
     else
     {
         return(StaticMethod(typeof(JsonSerializerUtil), methodName, refs.Context, refs.Field));
     }
 }
Пример #5
0
 public CodegenExpression CodegenSerialize(
     JsonSerializerForgeRefs refs,
     CodegenMethod method,
     CodegenClassScope classScope)
 {
     return ExprDotMethod(
         NewInstanceInner(_serializerClassName),
         "Serialize",
         refs.Context,
         refs.Field);
 }
Пример #6
0
 public CodegenExpression CodegenSerialize(
     JsonSerializerForgeRefs refs,
     CodegenMethod method,
     CodegenClassScope classScope)
 {
     return StaticMethod(
         typeof(JsonSerializerUtil),
         _serializeMethodName,
         refs.Context,
         refs.Field,
         NewInstanceInner(_factoryClassName));
 }
Пример #7
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));
        }
Пример #8
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));
        }
Пример #9
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));
        }
Пример #10
0
 public CodegenExpression CodegenSerialize(JsonSerializerForgeRefs refs, CodegenMethod method, CodegenClassScope classScope)
 {
     return(StaticMethod(delegateFactoryClassName, "WriteStatic", refs.Context, refs.Field));
 }
Пример #11
0
 public CodegenExpression CodegenSerialize(
     JsonSerializerForgeRefs refs,
     CodegenMethod method,
     CodegenClassScope classScope) => ProcCodegenWrite(refs, method, classScope);