forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlobExtensions.cs
More file actions
35 lines (31 loc) · 1.08 KB
/
Copy pathBlobExtensions.cs
File metadata and controls
35 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Text;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// Provides helper overloads to a <see cref = "Blob" />.
/// </summary>
public static class BlobExtensions
{
/// <summary>
/// Gets the blob content decoded as UTF-8.
/// </summary>
/// <param name="blob">The blob for which the content will be returned.</param>
/// <returns>Blob content as UTF-8</returns>
public static string ContentAsUtf8(this Blob blob)
{
Ensure.ArgumentNotNull(blob, "blob");
return Encoding.UTF8.GetString(blob.Content);
}
/// <summary>
/// Gets the blob content decoded as Unicode.
/// </summary>
/// <param name="blob">The blob for which the content will be returned.</param>
/// <returns>Blob content as unicode.</returns>
public static string ContentAsUnicode(this Blob blob)
{
Ensure.ArgumentNotNull(blob, "blob");
return Encoding.Unicode.GetString(blob.Content);
}
}
}