1717#endregion
1818
1919#if SUPPORT_LOAD_BALANCING
20+ using System . Collections ;
2021using System . Collections . Generic ;
2122using System . Collections . ObjectModel ;
2223using System . Diagnostics . CodeAnalysis ;
@@ -29,7 +30,7 @@ namespace Grpc.Net.Client.Balancer;
2930/// Note: Experimental API that can change or be removed without any prior notice.
3031/// </para>
3132/// </summary>
32- public sealed class BalancerAttributes : IDictionary < string , object ? >
33+ public sealed class BalancerAttributes : IDictionary < string , object ? > , IReadOnlyDictionary < string , object ? >
3334{
3435 /// <summary>
3536 /// Gets a read-only collection of metadata attributes.
@@ -61,22 +62,28 @@ private BalancerAttributes(IDictionary<string, object?> attributes)
6162 _attributes [ key ] = value ;
6263 }
6364 }
65+
6466 ICollection < string > IDictionary < string , object ? > . Keys => _attributes . Keys ;
6567 ICollection < object ? > IDictionary < string , object ? > . Values => _attributes . Values ;
6668 int ICollection < KeyValuePair < string , object ? > > . Count => _attributes . Count ;
67- bool ICollection < KeyValuePair < string , object ? > > . IsReadOnly => ( ( IDictionary < string , object ? > ) _attributes ) . IsReadOnly ;
69+ bool ICollection < KeyValuePair < string , object ? > > . IsReadOnly => _attributes . IsReadOnly ;
70+ IEnumerable < string > IReadOnlyDictionary < string , object ? > . Keys => _attributes . Keys ;
71+ IEnumerable < object ? > IReadOnlyDictionary < string , object ? > . Values => _attributes . Values ;
72+ int IReadOnlyCollection < KeyValuePair < string , object ? > > . Count => _attributes . Count ;
73+ object ? IReadOnlyDictionary < string , object ? > . this [ string key ] => _attributes [ key ] ;
6874 void IDictionary < string , object ? > . Add ( string key , object ? value ) => _attributes . Add ( key , value ) ;
69- void ICollection < KeyValuePair < string , object ? > > . Add ( KeyValuePair < string , object ? > item ) => ( ( IDictionary < string , object ? > ) _attributes ) . Add ( item ) ;
75+ void ICollection < KeyValuePair < string , object ? > > . Add ( KeyValuePair < string , object ? > item ) => _attributes . Add ( item ) ;
7076 void ICollection < KeyValuePair < string , object ? > > . Clear ( ) => _attributes . Clear ( ) ;
71- bool ICollection < KeyValuePair < string , object ? > > . Contains ( KeyValuePair < string , object ? > item ) => ( ( IDictionary < string , object ? > ) _attributes ) . Contains ( item ) ;
77+ bool ICollection < KeyValuePair < string , object ? > > . Contains ( KeyValuePair < string , object ? > item ) => _attributes . Contains ( item ) ;
7278 bool IDictionary < string , object ? > . ContainsKey ( string key ) => _attributes . ContainsKey ( key ) ;
73- void ICollection < KeyValuePair < string , object ? > > . CopyTo ( KeyValuePair < string , object ? > [ ] array , int arrayIndex ) =>
74- ( ( IDictionary < string , object ? > ) _attributes ) . CopyTo ( array , arrayIndex ) ;
79+ void ICollection < KeyValuePair < string , object ? > > . CopyTo ( KeyValuePair < string , object ? > [ ] array , int arrayIndex ) => _attributes . CopyTo ( array , arrayIndex ) ;
7580 IEnumerator < KeyValuePair < string , object ? > > IEnumerable < KeyValuePair < string , object ? > > . GetEnumerator ( ) => _attributes . GetEnumerator ( ) ;
76- System . Collections . IEnumerator System . Collections . IEnumerable . GetEnumerator ( ) => ( ( System . Collections . IEnumerable ) _attributes ) . GetEnumerator ( ) ;
81+ IEnumerator System . Collections . IEnumerable . GetEnumerator ( ) => ( ( System . Collections . IEnumerable ) _attributes ) . GetEnumerator ( ) ;
7782 bool IDictionary < string , object ? > . Remove ( string key ) => _attributes . Remove ( key ) ;
78- bool ICollection < KeyValuePair < string , object ? > > . Remove ( KeyValuePair < string , object ? > item ) => ( ( IDictionary < string , object ? > ) _attributes ) . Remove ( item ) ;
83+ bool ICollection < KeyValuePair < string , object ? > > . Remove ( KeyValuePair < string , object ? > item ) => _attributes . Remove ( item ) ;
7984 bool IDictionary < string , object ? > . TryGetValue ( string key , out object ? value ) => _attributes . TryGetValue ( key , out value ) ;
85+ bool IReadOnlyDictionary < string , object ? > . ContainsKey ( string key ) => _attributes . ContainsKey ( key ) ;
86+ bool IReadOnlyDictionary < string , object ? > . TryGetValue ( string key , out object ? value ) => _attributes . TryGetValue ( key , out value ) ;
8087
8188 /// <summary>
8289 /// Gets the value associated with the specified key.
0 commit comments