public RestClient(
     IHttpClientFactory clientFactory,
     IRequestMessageFactory requestMessageFactory,
     IResponseFactory responseFactory)
 {
     _clientFactory         = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory));
     _requestMessageFactory = requestMessageFactory ?? throw new ArgumentNullException(nameof(requestMessageFactory));
     _responseFactory       = responseFactory ?? throw new ArgumentNullException(nameof(responseFactory));
 }
Beispiel #2
0
        /// <summary>
        /// 创建请求消息实例。
        /// </summary>
        /// <param name="requestMessageFactory">请求消息工厂。</param>
        /// <param name="stream">数据流。</param>
        /// <returns>请求消息。</returns>
        public static IMessageBase CreateRequestMessage(this IRequestMessageFactory requestMessageFactory, Stream stream)
        {
            stream.NotNull("stream");
            var bytes = new byte[stream.Length];

            stream.Read(bytes, 0, bytes.Length);
            var content = Encoding.UTF8.GetString(bytes);

            return(requestMessageFactory.CreateRequestMessage(content));
        }
Beispiel #3
0
 /// <summary>
 /// 创建请求消息实例。
 /// </summary>
 /// <typeparam name="T">请求消息类型。</typeparam>
 /// <param name="requestMessageFactory">请求消息工厂。</param>
 /// <param name="xmlContent">xml内容。</param>
 /// <returns>请求消息。</returns>
 public static T CreateRequestMessage <T>(this IRequestMessageFactory requestMessageFactory, string xmlContent) where T : class, IMessageBase
 {
     return(requestMessageFactory.CreateRequestMessage(xmlContent) as T);
 }