Skip to content

Commit

Permalink
Added IReadOnlyDictionary to HttpRequestOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
xrem committed Jun 1, 2023
1 parent ac5febd commit f9b3953
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/libraries/System.Net.Http/ref/System.Net.Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ public HttpRequestOptionsKey(string key) {}
public string Key { get { throw null; } }
}

public sealed class HttpRequestOptions : System.Collections.Generic.IDictionary<string, object?>
public sealed class HttpRequestOptions : System.Collections.Generic.IDictionary<string, object?>, System.Collections.Generic.IReadOnlyDictionary<string, object?>
{
bool System.Collections.Generic.IReadOnlyDictionary<string, object?>.ContainsKey(string key) { throw null; }
int System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<string, object?>>.Count { get { throw null; } }
void System.Collections.Generic.IDictionary<string, object?>.Add(string key, object? value) { throw null; }
System.Collections.Generic.ICollection<string> System.Collections.Generic.IDictionary<string, object?>.Keys { get { throw null; } }
System.Collections.Generic.ICollection<object?> System.Collections.Generic.IDictionary<string, object?>.Values { get { throw null; } }
Expand All @@ -297,6 +299,10 @@ public sealed class HttpRequestOptions : System.Collections.Generic.IDictionary<
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public bool TryGetValue<TValue>(HttpRequestOptionsKey<TValue> key, [MaybeNullWhen(false)] out TValue value) { throw null; }
public void Set<TValue>(HttpRequestOptionsKey<TValue> key, TValue value) { throw null; }
bool System.Collections.Generic.IReadOnlyDictionary<string, object?>.TryGetValue(string key, out object? value) { throw null; }
object? System.Collections.Generic.IReadOnlyDictionary<string, object?>.this[string key] { get { throw null; } }
System.Collections.Generic.IEnumerable<string> System.Collections.Generic.IReadOnlyDictionary<string, object?>.Keys { get { throw null; } }
System.Collections.Generic.IEnumerable<object?> System.Collections.Generic.IReadOnlyDictionary<string, object?>.Values { get { throw null; } }
}

public partial class HttpResponseMessage : System.IDisposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ namespace System.Net.Http
/// <summary>
/// Represents a collection of options for an HTTP request.
/// </summary>
public sealed class HttpRequestOptions : IDictionary<string, object?>
public sealed class HttpRequestOptions : IDictionary<string, object?>, IReadOnlyDictionary<string, object?>
{
private Dictionary<string, object?> Options { get; } = new Dictionary<string, object?>();
bool IReadOnlyDictionary<string, object?>.TryGetValue(string key, out object? value) => Options.TryGetValue(key, out value);
object? IReadOnlyDictionary<string, object?>.this[string key] => Options[key];
IEnumerable<string> IReadOnlyDictionary<string, object?>.Keys => Options.Keys;
IEnumerable<object?> IReadOnlyDictionary<string, object?>.Values => Options.Values;
object? IDictionary<string, object?>.this[string key]
{
get
Expand All @@ -38,7 +42,9 @@ public sealed class HttpRequestOptions : IDictionary<string, object?>
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => ((System.Collections.IEnumerable)Options).GetEnumerator();
bool IDictionary<string, object?>.Remove(string key) => Options.Remove(key);
bool ICollection<KeyValuePair<string, object?>>.Remove(KeyValuePair<string, object?> item) => ((IDictionary<string, object?>)Options).Remove(item);
bool IReadOnlyDictionary<string, object?>.ContainsKey(string key) => Options.ContainsKey(key);
bool IDictionary<string, object?>.TryGetValue(string key, out object? value) => Options.TryGetValue(key, out value);
int IReadOnlyCollection<KeyValuePair<string, object?>>.Count => Options.Count;

/// <summary>
/// Initializes a new instance of the HttpRequestOptions class.
Expand Down

0 comments on commit f9b3953

Please sign in to comment.