Skip to content

Commit

Permalink
[#1] - Provided an overload for the HalClient construct to accept a l…
Browse files Browse the repository at this point in the history
…ist of MediaTypeFormatters.
  • Loading branch information
eoin55 committed Feb 29, 2016
1 parent b45b3c8 commit f0319ba
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions Src/HoneyBear.HalClient/HalClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,37 @@ namespace HoneyBear.HalClient
public class HalClient : IHalClient
{
private readonly IJsonHttpClient _client;
private readonly IEnumerable<MediaTypeFormatter> _formatters;
private IEnumerable<IResource> _current = Enumerable.Empty<IResource>();

private static readonly List<MediaTypeFormatter> _formatters =
new List<MediaTypeFormatter> {new HalJsonMediaTypeFormatter()};
private static readonly IEnumerable<MediaTypeFormatter> _defaultFormatters =
new[] {new HalJsonMediaTypeFormatter()};

/// <summary>
/// Creates an instance of the <see cref="HalClient"/> class.
/// </summary>
/// <param name="client">The <see cref="System.Net.Http.HttpClient"/> to use.</param>
public HalClient(HttpClient client)
/// <param name="formatters">
/// Specifies the list of <see cref="MediaTypeFormatter"/>s to use.
/// Default is <see cref="HalJsonMediaTypeFormatter"/>.
/// </param>
public HalClient(
HttpClient client,
IEnumerable<MediaTypeFormatter> formatters)
{
_client = new JsonHttpClient(client);
_formatters = formatters;
}

/// <summary>
/// Creates an instance of the <see cref="HalClient"/> class.
/// </summary>
/// <param name="client">The <see cref="System.Net.Http.HttpClient"/> to use.</param>
public HalClient(
HttpClient client)
: this(client, _defaultFormatters)
{

}

/// <summary>
Expand All @@ -43,6 +62,7 @@ public HalClient()
internal HalClient(IJsonHttpClient client)
{
_client = client;
_formatters = _defaultFormatters;
}

/// <summary>
Expand Down

0 comments on commit f0319ba

Please sign in to comment.