/// <summary> /// Gets the blob content as it would be checked out to the /// working directory, decoded with the specified encoding, /// or according to byte order marks, with UTF8 as fallback, /// if <paramref name="encoding"/> is null. /// </summary> /// <param name="blob">The blob for which the content will be returned.</param> /// <param name="filteringOptions">Parameter controlling content filtering behavior</param> /// <param name="encoding">The encoding of the text. (default: detected or UTF8)</param> /// <returns>Blob content as text.</returns> public static string ContentAsText(this Blob blob, FilteringOptions filteringOptions, Encoding encoding = null) { Ensure.ArgumentNotNull(blob, "blob"); Ensure.ArgumentNotNull(filteringOptions, "filteringOptions"); using(var reader = new StreamReader(blob.ContentStream(filteringOptions), encoding ?? Encoding.UTF8, encoding == null)) { return reader.ReadToEnd(); } }
/// <summary> /// Gets the blob content in a <see cref="Stream"/> as it would be /// checked out to the working directory. /// <param name="filteringOptions">Parameter controlling content filtering behavior</param> /// </summary> public virtual Stream GetContentStream(FilteringOptions filteringOptions) { Ensure.ArgumentNotNull(filteringOptions, "filteringOptions"); return Proxy.git_blob_filtered_content_stream(repo.Handle, Id, filteringOptions.HintPath, false); }
/// <summary> /// Gets the blob content as it would be checked out to the /// working directory, decoded with the specified encoding, /// or according to byte order marks, with UTF8 as fallback, /// if <paramref name="encoding"/> is null. /// </summary> /// <param name="filteringOptions">Parameter controlling content filtering behavior</param> /// <param name="encoding">The encoding of the text. (default: detected or UTF8)</param> /// <returns>Blob content as text.</returns> public virtual string GetContentText(FilteringOptions filteringOptions, Encoding encoding) { Ensure.ArgumentNotNull(filteringOptions, "filteringOptions"); return(ReadToEnd(GetContentStream(filteringOptions), encoding)); }
/// <summary> /// Gets the blob content as it would be checked out to the /// working directory, decoded with the specified encoding, /// or according to byte order marks, with UTF8 as fallback, /// if <paramref name="encoding"/> is null. /// </summary> /// <param name="filteringOptions">Parameter controlling content filtering behavior</param> /// <param name="encoding">The encoding of the text. (default: detected or UTF8)</param> /// <returns>Blob content as text.</returns> public virtual string GetContentText(FilteringOptions filteringOptions, Encoding encoding) { Ensure.ArgumentNotNull(filteringOptions, "filteringOptions"); return ReadToEnd(GetContentStream(filteringOptions), encoding); }
/// <summary> /// Gets the blob content, decoded with UTF8 encoding if the encoding cannot be detected /// </summary> /// <param name="filteringOptions">Parameter controlling content filtering behavior</param> /// <returns>Blob content as text.</returns> public virtual string GetContentText(FilteringOptions filteringOptions) { return GetContentText(filteringOptions, null); }
/// <summary> /// Gets the blob content in a <see cref="Stream"/> as it would be /// checked out to the working directory. /// <param name="filteringOptions">Parameter controlling content filtering behavior</param> /// </summary> /// <exception cref="NotFoundException">Throws if blob is missing</exception> public virtual Stream GetContentStream(FilteringOptions filteringOptions) { Ensure.ArgumentNotNull(filteringOptions, "filteringOptions"); return(Proxy.git_blob_filtered_content_stream(repo.Handle, Id, filteringOptions.HintPath, false)); }
/// <summary> /// Gets the blob content, decoded with UTF8 encoding if the encoding cannot be detected /// </summary> /// <param name="filteringOptions">Parameter controlling content filtering behavior</param> /// <returns>Blob content as text.</returns> /// <exception cref="NotFoundException">Throws if blob is missing</exception> public virtual string GetContentText(FilteringOptions filteringOptions) { return(GetContentText(filteringOptions, null)); }
public static string ContentAsText(this Blob blob, FilteringOptions filteringOptions, Encoding encoding = null) { return GetContentText(blob, filteringOptions, encoding); }