// // IResponseResolver.cs // // Author: // MiNG // // Copyright (c) 2018 Alibaba Cloud // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; using System.Threading.Tasks; namespace Aliyun.Api.LogService.Infrastructure.Protocol { /// /// 响应消息解释器。 /// public interface IResponseResolver { /// /// 使用 作为目标对象类型。 /// /// 目标对象类型 /// 带有结果对象类型的响应消息解释器。 IResponseResolver With() where TResult : class; /// /// 设置解压缩原始数据的处理器,此操作会使默认解压缩处理器失效。 /// /// 解压缩处理器。 /// 当前解释器。 IResponseResolver Decompress(Func decompressor); /// /// 设置反序列化原始数据的处理器,此操作会使默认反序列化处理器失效。 /// /// 反序列化处理器。 /// 结果对象类型。 /// 带有结果对象类型的响应消息解释器。 IResponseResolver Deserialize(Func deserializer) where TResult : class; /// /// 解释响应消息。 /// /// 异步解释结果。 Task ResolveAsync(); /// /// 解释响应消息,并反序列化为 。 /// /// 结果对象类型。 /// 异步解释结果。 Task> ResolveAsync() where TResult : class; } /// /// 带有结果对象类型的响应消息解释器。 /// /// 结果对象类型。 public interface IResponseResolver where TResult : class { /// /// 设置解压缩原始数据的处理器,此操作会使默认解压缩处理器失效。 /// /// 解压缩处理器。 /// 当前解释器。 IResponseResolver Decompress(Func decompressor); /// /// 设置反序列化原始数据的处理器,此操作会使默认反序列化处理器失效。 /// /// 反序列化处理器。 /// 当前解释器。 IResponseResolver Deserialize(Func deserializer); /// /// 解释响应消息,并反序列化为 。 /// /// 异步解释结果。 Task> ResolveAsync(); /// /// 解释响应消息,反序列化为 后通过 转换为 。 /// /// 结果转换器。 /// 转换后结果对象类型。 /// 异步解释结果。 Task> ResolveAsync(Func transformer) where TNewResult : class; } }