Beispiel #1
0
        internal virtual Expression GetDeserializerExpression(ParameterExpression jsonReaderParam, ParameterExpression settingsParam)
        {
            var resultVar     = Expression.Variable(Type, "result");
            var memberNameVar = Expression.Variable(typeof(StringChunk), "memberName");
            var comparerVar   = Expression.Variable(typeof(IEqualityComparer <StringChunk>), "comparer");

            var breakLabel    = Expression.Label("break");
            var continueLabel = Expression.Label("continue");

            return(Expression.Block(
                       new[] { resultVar, memberNameVar, comparerVar },
                       MakeSureBlockStartsWith(jsonReaderParam, '{'),
                       Expression.Call(jsonReaderParam, ExpressionReflector.GetMethodInfo <JsonReader>(r => r.ReadNextChar())),
                       Expression.Assign(resultVar, CreateParameterLessFactory()),
                       Expression.Assign(comparerVar, Expression.Property(settingsParam, ExpressionReflector.GetPropertyInfo((JsonSettings s) => s.Comparer))),
                       new WhileExpression(
                           Expression.Equal(
                               Expression.Call(jsonReaderParam, nameof(JsonReader.CurrentChar), Type.EmptyTypes),
                               Expression.Constant('"')),
                           GetMemberExpressionLoopBlock(jsonReaderParam, jsonReaderParam, resultVar, memberNameVar, comparerVar, settingsParam, breakLabel, continueLabel),
                           breakLabel,
                           continueLabel),
                       resultVar));
        }