Example #1
0
        public static RpcParameterInfo FromParameter(ParameterInfo parameterInfo)
        {
            Type             parameterType = parameterInfo.ParameterType;
            RpcParameterType type          = RpcParameterUtil.GetRpcType(parameterType);

            return(new RpcParameterInfo(parameterInfo.Name !, type, parameterInfo.ParameterType, parameterInfo.IsOptional));
        }
Example #2
0
 public RpcParameterInfo(string name, RpcParameterType type, Type rawType, bool isOptional)
 {
     this.Name       = name;
     this.Type       = type;
     this.RawType    = rawType;
     this.IsOptional = isOptional;
 }
            static RpcParameterInfo ExtractParam(ParameterInfo parameterInfo)
            {
                Type             parameterType = parameterInfo.ParameterType;
                RpcParameterType type          = RpcParameterUtil.GetRpcType(parameterType);

                return(new RpcParameterInfo(parameterInfo.Name, type, parameterInfo.ParameterType, parameterInfo.IsOptional));
            }
Example #4
0
        private JsonBytesRpcParameter GetParameter(ref Utf8JsonReader jsonReader, Memory <byte> bytes)
        {
            int start = (int)jsonReader.TokenStartIndex;
            RpcParameterType paramType = GetParameters(ref jsonReader);
            int length = (int)jsonReader.BytesConsumed - start;

            jsonReader.Read();
            return(new JsonBytesRpcParameter(paramType, bytes.Slice(start, length), this.serverConfig.Value?.JsonSerializerSettings));
        }
Example #5
0
        static JsonBytesRpcParameter FromRaw(object?value, JsonSerializerOptions?serializerOptions = null)
        {
            string           json = JsonSerializer.Serialize(value, serializerOptions);
            RpcParameterType type = value != null?RpcParameterUtil.GetRpcType(value.GetType()) : RpcParameterType.Null;

            JsonElement element = JsonDocument.Parse(json).RootElement;

            return(new JsonBytesRpcParameter(type, element, serializerOptions));
        }
Example #6
0
        public void Create_EmptyListParam_Valid()
        {
            string methodName = "Test";

            RpcParameterType[] parameters = new RpcParameterType[0];
            var signature = RpcRequestSignature.Create(methodName, parameters);

            Assert.Equal(methodName, signature.GetMethodName().ToString());
            Assert.False(signature.HasParameters);
            Assert.False(signature.IsDictionary);
            Assert.Equal(parameters, signature.ParametersAsList);
        }
Example #7
0
        private JsonBytesRpcParameter GetParameter(JsonElement element)
        {
            RpcParameterType paramType = GetParameters(element);

            return(new JsonBytesRpcParameter(paramType, element, this.serverConfig.Value.JsonSerializerSettings));
        }