Skip to content

Commit

Permalink
IDE0063: 'using' statement can be simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
raman-m committed Aug 11, 2023
1 parent 3fe038d commit f5e6a89
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/Ocelot/Request/Mapper/RequestMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ private static async Task<HttpContent> MapContent(HttpRequest request)
{
foreach (var f in request.Form.Files)
{
using (var memStream = new MemoryStream())
{
await f.CopyToAsync(memStream);
var fileContent = new ByteArrayContent(memStream.ToArray());
((MultipartFormDataContent)content).Add(fileContent, f.Name, f.FileName);
}
using var memStream = new MemoryStream();
await f.CopyToAsync(memStream);
var fileContent = new ByteArrayContent(memStream.ToArray());
((MultipartFormDataContent)content).Add(fileContent, f.Name, f.FileName);
}
}

Expand Down Expand Up @@ -141,11 +139,9 @@ private static async Task<byte[]> ToByteArray(Stream stream)
{
await using (stream)
{
using (var memStream = new MemoryStream())
{
await stream.CopyToAsync(memStream);
return memStream.ToArray();
}
using var memStream = new MemoryStream();
await stream.CopyToAsync(memStream);
return memStream.ToArray();
}
}
}
Expand Down

0 comments on commit f5e6a89

Please sign in to comment.