11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT License.
3+ using System . Collections . ObjectModel ;
34
45namespace System . ClientModel . Primitives ;
56
@@ -28,6 +29,7 @@ public ClientConnection(string id, string locator, object credential, Credential
2829 Locator = locator ;
2930 Credential = credential ;
3031 CredentialKind = credentialKind ;
32+ Metadata = new Dictionary < string , string > ( ) ;
3133 }
3234
3335 /// <summary>
@@ -45,6 +47,7 @@ public ClientConnection(string id, string locator)
4547 Id = id ;
4648 Locator = locator ;
4749 CredentialKind = CredentialKind . None ;
50+ Metadata = new ReadOnlyDictionary < string , string > ( new Dictionary < string , string > ( ) ) ;
4851 }
4952
5053 /// <summary>
@@ -59,6 +62,23 @@ internal ClientConnection(string id, string locator, CredentialKind credentialKi
5962 Id = id ;
6063 Locator = locator ;
6164 CredentialKind = credentialKind ;
65+ Metadata = new ReadOnlyDictionary < string , string > ( new Dictionary < string , string > ( ) ) ;
66+ }
67+
68+ /// <summary>
69+ /// Initializes a new instance of the <see cref="ClientConnection"/> struct with the specified subclient ID.
70+ /// It is only for the JSON serializer.
71+ /// </summary>
72+ /// <param name="metadata">The connection metadata.</param>
73+ /// <param name="id">The identifier for the connection.</param>
74+ /// <param name="locator">The endpoint or resource identifier.</param>
75+ /// <param name="credentialKind">The kind of connection used by the client</param>
76+ internal ClientConnection ( IReadOnlyDictionary < string , string > metadata , string id , string locator , CredentialKind credentialKind )
77+ {
78+ Id = id ;
79+ Locator = locator ;
80+ CredentialKind = credentialKind ;
81+ Metadata = metadata ;
6282 }
6383
6484 /// <summary>
@@ -96,4 +116,7 @@ public bool TryGetLocatorAsUri(out Uri? uri)
96116 /// </summary>
97117 /// <returns>A string in the format 'Id => Locator'.</returns>
98118 public override string ToString ( ) => $ "{ Id } => { Locator } ";
119+
120+ /// <summary> Metadata of the connection. </summary>
121+ public IReadOnlyDictionary < string , string > Metadata { get ; }
99122}
0 commit comments