17
17
#endregion
18
18
19
19
#if SUPPORT_LOAD_BALANCING
20
+ using System . Collections ;
20
21
using System . Collections . Generic ;
21
22
using System . Collections . ObjectModel ;
22
23
using System . Diagnostics . CodeAnalysis ;
@@ -29,7 +30,7 @@ namespace Grpc.Net.Client.Balancer;
29
30
/// Note: Experimental API that can change or be removed without any prior notice.
30
31
/// </para>
31
32
/// </summary>
32
- public sealed class BalancerAttributes : IDictionary < string , object ? >
33
+ public sealed class BalancerAttributes : IDictionary < string , object ? > , IReadOnlyDictionary < string , object ? >
33
34
{
34
35
/// <summary>
35
36
/// Gets a read-only collection of metadata attributes.
@@ -61,22 +62,28 @@ private BalancerAttributes(IDictionary<string, object?> attributes)
61
62
_attributes [ key ] = value ;
62
63
}
63
64
}
65
+
64
66
ICollection < string > IDictionary < string , object ? > . Keys => _attributes . Keys ;
65
67
ICollection < object ? > IDictionary < string , object ? > . Values => _attributes . Values ;
66
68
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 ] ;
68
74
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 ) ;
70
76
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 ) ;
72
78
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 ) ;
75
80
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 ( ) ;
77
82
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 ) ;
79
84
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 ) ;
80
87
81
88
/// <summary>
82
89
/// Gets the value associated with the specified key.
0 commit comments