<PackageReference Include="System.ClientModel" Version="1.6.1" />

ClientConnection

public struct ClientConnection
Represents the connection options for a client.
using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime.CompilerServices; namespace System.ClientModel.Primitives { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public readonly struct ClientConnection { public string Id { get; } public string Locator { get; } [System.Runtime.CompilerServices.Nullable(2)] [field: System.Runtime.CompilerServices.Nullable(2)] public object Credential { [System.Runtime.CompilerServices.NullableContext(2)] get; } public CredentialKind CredentialKind { get; } public IReadOnlyDictionary<string, string> Metadata { get; } public ClientConnection(string id, string locator, object credential, CredentialKind credentialKind) { if (string.IsNullOrWhiteSpace(id)) throw new ArgumentException("Id cannot be null or empty.", "id"); if (string.IsNullOrWhiteSpace(locator)) throw new ArgumentException("Locator cannot be null or empty.", "locator"); if (credential == null) throw new ArgumentNullException("credential", "Credential cannot be null."); Id = id; Locator = locator; Credential = credential; CredentialKind = credentialKind; Metadata = new Dictionary<string, string>(); } public ClientConnection(string id, string locator) { Credential = null; if (string.IsNullOrWhiteSpace(id)) throw new ArgumentException("Id cannot be null or empty.", "id"); if (string.IsNullOrWhiteSpace(locator)) throw new ArgumentException("Locator cannot be null or empty.", "locator"); Id = id; Locator = locator; CredentialKind = CredentialKind.None; Metadata = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()); } internal ClientConnection(string id, string locator, CredentialKind credentialKind) { Credential = null; Id = id; Locator = locator; CredentialKind = credentialKind; Metadata = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>()); } internal ClientConnection(IReadOnlyDictionary<string, string> metadata, string id, string locator, CredentialKind credentialKind) { Credential = null; Id = id; Locator = locator; CredentialKind = credentialKind; Metadata = metadata; } [System.Runtime.CompilerServices.NullableContext(2)] public bool TryGetLocatorAsUri(out Uri uri) { return Uri.TryCreate(Locator, UriKind.Absolute, out uri); } public override string ToString() { return Id + " => " + Locator; } } }