8000 Minor refactoring · GiTechLab/libgit2sharp@41a1bae · GitHub
[go: up one dir, main page]

Skip to content

Commit 41a1bae

Browse files
committed
Minor refactoring
1 parent 24dfd15 commit 41a1bae

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

LibGit2Sharp/BlobExtensions.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ public static string GetContentText(this Blob blob, Encoding encoding = null)
2222
{
2323
Ensure.ArgumentNotNull(blob, "blob");
2424

25-
using (var reader = new StreamReader(blob.GetContentStream(), encoding ?? Encoding.UTF8, encoding == null))
26-
{
27-
return reader.ReadToEnd();
28-
}
25+
return ReadToEnd(blob.GetContentStream, encoding);
2926
}
3027

3128
/// <summary>
@@ -43,7 +40,12 @@ public static string GetContentText(this Blob blob, FilteringOptions filteringOp
4340
Ensure.ArgumentNotNull(blob, "blob");
4441
Ensure.ArgumentNotNull(filteringOptions, "filteringOptions");
4542

46-
using (var reader = new StreamReader(blob.GetContentStream(filteringOptions), encoding ?? Encoding.UTF8, encoding == null))
43+
return ReadToEnd(() => blob.GetContentStream(filteringOptions), encoding);
44+
}
45+
46+
private static string ReadToEnd(Func<Stream> streamProvider, Encoding encoding)
47+
{
48+
using (var reader = new StreamReader(streamProvider(), encoding ?? Encoding.UTF8, encoding == null))
4749
{
4850
return reader.ReadToEnd();
4951
}

0 commit comments

Comments
 (0)
0