Пример #1
0
        private object[] GetParametersUsingCompiledDelgates(RpcJsonReader reader, ConverterInfo converter, JsonSerializer serializer)
        {
            if (reader.Read())
            {
                if (reader.TokenType == JsonToken.StartArray)
                {
                    reader.Read();

                    var deserializer = converter.ParameterArrayDeserializer ??
                                       (converter.ParameterArrayDeserializer =
                                            _parameterArrayDeserializerBuilder.BuildDeserializer(converter.ExposedMethod));

                    return(deserializer(reader.Context, reader, serializer));
                }

                if (reader.TokenType == JsonToken.StartObject)
                {
                    reader.Read();

                    var deserializer = converter.NamedParamsDeserializer ??
                                       (converter.NamedParamsDeserializer =
                                            _namedParameterDeserializerBuilder.BuildDeserializer(converter.ExposedMethod));

                    return(deserializer(reader.Context, reader, serializer));
                }

                if (reader.TokenType == JsonToken.Null)
                {
                    return(new object[0]);
                }
            }

            throw new Exception("Could not read parameters");
        }