File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System . Text ;
2
+
3
+ namespace LibGit2Sharp
4
+ {
5
+ /// <summary>
6
+ /// Provides helper overloads to a <see cref = "Blob" />.
7
+ /// </summary>
8
+ public static class BlobExtensions
9
+ {
10
+ /// <summary>
11
+ /// Gets the blob content decoded as UTF-8.
12
+ /// </summary>
13
+ /// <param name="blob">The blob for which the content will be returned.</param>
14
+ /// <returns>Blob content as UTF-8</returns>
15
+ public static string ContentAsUtf8 ( this Blob blob )
16
+ {
17
+ return Encoding . UTF8 . GetString ( blob . Content ) ;
18
+ }
19
+
20
+ /// <summary>
21
+ /// Gets the blob content decoded as Unicode.
22
+ /// </summary>
23
+ /// <param name="blob">The blob for which the content will be returned.</param>
24
+ /// <returns>Blob content as unicode.</returns>
25
+ public static string ContentAsUnicode ( this Blob blob )
26
+ {
27
+ return Encoding . Unicode . GetString ( blob . Content ) ;
28
+ }
29
+ }
30
+ }
Original file line number Diff line number Diff line change 57
57
<ItemGroup >
58
58
<Compile Include =" AbbreviatedObjectId.cs" />
59
59
<Compile Include =" Blob.cs" />
60
+ <Compile Include =" BlobExtensions.cs" />
60
61
<Compile Include =" Branch.cs" />
61
62
<Compile Include =" BranchCollection.cs" />
62
63
<Compile Include =" Changes.cs" />
You can’t perform that action at this time.
0 commit comments