File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 11using System ;
2+ using System . IO ;
23using System . Net ;
34using System . Net . Http ;
5+ using System . Text ;
46using System . Threading . Tasks ;
57using Cuiliang . AliyunOssSdk . Api . Common . Consts ;
68using Cuiliang . AliyunOssSdk . Entites ;
@@ -116,9 +118,14 @@ private async Task<OssResult<TResult>> ProcessResponseInternal(HttpResponseMessa
116118 //错误的http代码
117119 if ( response . Content ? . Headers . ContentLength > 0 )
118120 {
121+ //var responseContent = await response.Content.ReadAsStreamAsync();
122+ //var errorResult =
123+ // SerializeHelper.Deserialize<ErrorResult>(responseContent);
124+
125+ var responseContent = await response . Content . ReadAsStringAsync ( ) ;
119126 var errorResult =
120- SerializeHelper . Deserialize < ErrorResult > ( await response . Content . ReadAsStreamAsync ( ) ) ;
121-
127+ SerializeHelper . Deserialize < ErrorResult > ( responseContent ) ;
128+
122129 return new OssResult < TResult > ( )
123130 {
124131 IsSuccess = false ,
Original file line number Diff line number Diff line change @@ -28,6 +28,24 @@ public static T Deserialize<T>(Stream xmlStream)
2828
2929 }
3030
31+ /// <summary>
32+ /// XML 文本 -》 对象
33+ /// </summary>
34+ /// <typeparam name="T"></typeparam>
35+ /// <param name="stringContent"></param>
36+ /// <returns></returns>
37+ public static T Deserialize < T > ( string stringContent )
38+ {
39+ var serializer = new XmlSerializer ( typeof ( T ) ) ;
40+
41+ using ( TextReader reader = new StringReader ( stringContent ) )
42+ {
43+ return ( T ) serializer . Deserialize ( reader ) ;
44+ }
45+
46+
47+ }
48+
3149 /// <summary>
3250 /// 将一个对象序列化为XML字符串
3351 /// </summary>
You can’t perform that action at this time.
0 commit comments