public Message SerializeRequest(MessageVersion messageVersion, object[] parameters)
        {
            var serializer = JsonSerializer.Create(settingsProvider());

            using (var stream = new MemoryStream())
            {
                using (var writer = new StreamWriter(stream))
                    using (var jsonWriter = new JsonTextWriter(writer))
                    {
                        jsonWriter.WriteStartObject();
                        foreach (var part in operationParameters)
                        {
                            object paramValue = parameters[part.Index];

                            if (paramValue != null)
                            {
                                jsonWriter.WritePropertyName(part.Name);
                                serializer.Serialize(jsonWriter, paramValue);
                            }
                        }

                        jsonWriter.WriteEndObject();
                    }

                var message = MessageBinaryHelper.SerializeMessage(stream.ToArray());

                message.Properties[SolaceConstants.ApplicationMessageTypeKey] = applicationMessageType;
                message.Properties[SolaceConstants.CorrelationIdKey]          = new RequestCorrelationState();

                return(message);
            }
        }
        public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
        {
            var message = MessageBinaryHelper.SerializeMessage(Converter.SerializeReply(result));

            message.Properties["ApplicationMessageType"] = ReplyApplicationMessageType;

            return(message);
        }
        public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
        {
            var reply = MessageBinaryHelper.SerializeMessage(Serialize(result));

            reply.Properties[SolaceConstants.ApplicationMessageTypeKey] = replyApplicationMessageType;

            return(reply);
        }
        public Message SerializeRequest(MessageVersion messageVersion, object[] parameters)
        {
            var message = MessageBinaryHelper.SerializeMessage(
                binaryParameterIndex != null
                    ? (byte[])parameters[binaryParameterIndex.Value]
                    : null);

            message.Properties["ApplicationMessageType"] = ApplicationMessageType;
            message.Properties["CorrelationId"]          = new RequestCorrelationState();

            if (IsOneWay)
            {
                message.Properties["IsOneWay"] = true;
            }

            return(message);
        }
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (HandleError(error))
            {
                Message message;

                using (var stream = new MemoryStream())
                {
                    WriteException(error, stream,
                                   fault?.Properties[SolaceConstants.ApplicationMessageTypeKey].ToString());
                    message = MessageBinaryHelper.SerializeMessage(stream.ToArray());
                }

                if (fault != null)
                {
                    message.Properties.CopyProperties(fault.Properties);
                    message.Headers.CopyHeadersFrom(fault.Headers);
                    fault.Close();
                }

                message.Properties[SolaceConstants.ApplicationMessageTypeKey] = "Fault";
                fault = message;
            }
        }
        public Message SerializeRequest(MessageVersion messageVersion, object[] parameters)
        {
            var message = MessageBinaryHelper.SerializeMessage(Converter.SerializeRequest(parameters));

            if (senderIdIndex != null)
            {
                object obj = parameters[senderIdIndex.Value];

                if (obj != null)
                {
                    message.Properties["SenderId"] = obj;
                }
            }

            message.Properties["ApplicationMessageType"] = ApplicationMessageType;
            message.Properties["CorrelationId"]          = new RequestCorrelationState();

            if (IsOneWay)
            {
                message.Properties["IsOneWay"] = true;
            }

            return(message);
        }