コード例 #1
0
        private static AcsError ReadError(HttpRequest httpResponse, FormatType?format)
        {
            var responseEndpoint = "Error";
            var reader           = ReaderFactory.CreateInstance(format);
            var context          = new UnmarshallerContext();
            var body             = Encoding.UTF8.GetString(httpResponse.Content);

            context.ResponseDictionary = null == reader ? new Dictionary <string, string>() : reader.Read(body, responseEndpoint);
            return(AcsErrorUnmarshaller.Unmarshall(context));
        }
コード例 #2
0
        private AcsError readError(HttpResponse httpResponse, FormatType format)
        {
            String              responseEndpoint = "Error";
            IReader             reader           = ReaderFactory.CreateInstance(format);
            UnmarshallerContext context          = new UnmarshallerContext();
            String              stringContent    = getResponseContent(httpResponse);

            context.ResponseDictionary = reader.Read(stringContent, responseEndpoint);

            return(AcsErrorUnmarshaller.Unmarshall(context));
        }
コード例 #3
0
        private AcsError ReadError <T>(AcsRequest <T> request, HttpResponse httpResponse, FormatType?format)
            where T : AcsResponse
        {
            var responseEndpoint = "Error";
            var reader           = ReaderFactory.CreateInstance(format);
            var context          = new UnmarshallerContext();
            var body             = Encoding.Default.GetString(httpResponse.Content);

            context.ResponseDictionary =
                null == reader ? new Dictionary <string, string>() : reader.Read(body, responseEndpoint);

            return(AcsErrorUnmarshaller.Unmarshall(context));
        }
コード例 #4
0
        private AcsError ReadError <T>(AcsRequest <T> request, HttpResponse httpResponse, FormatType?format) where T : AcsResponse
        {
            string              responseEndpoint = "Error";
            IReader             reader           = ReaderFactory.CreateInstance(format);
            UnmarshallerContext context          = new UnmarshallerContext();
            string              body             = System.Text.Encoding.Default.GetString(httpResponse.Content);

            if (null == reader)
            {
                context.ResponseDictionary = new Dictionary <string, string>();
            }
            else
            {
                context.ResponseDictionary = reader.Read(body, responseEndpoint);
            }
            return(AcsErrorUnmarshaller.Unmarshall(context));
        }
コード例 #5
0
        public void Unmarshall()
        {
            UnmarshallerContext unmarshallerContext = new UnmarshallerContext();

            if (unmarshallerContext.ResponseDictionary == null)
            {
                unmarshallerContext.ResponseDictionary = new Dictionary <string, string>
                {
                    { "Error.RequestId", "RequestId" },
                    { "Error.Code", "ErrorCode" },
                    { "Error.Message", "ErrorMessage" }
                };
            }
            AcsError error = AcsErrorUnmarshaller.Unmarshall(unmarshallerContext);

            Assert.Equal("ErrorCode", error.ErrorCode);
            Assert.Equal("ErrorMessage", error.ErrorMessage);
            Assert.Equal("RequestId", error.RequestId);
        }