// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // namespace Microsoft.SqlTools.DataProtocol.Contracts.Connection { /// /// Message format for the initial connection request /// /// /// If this contract is ever changed, be sure to update ConnectionDetailsExtensions methods. /// public class ConnectionDetails : GeneralRequestDetails, IConnectionSummary { public ConnectionDetails() : base() { } /// /// Gets or sets the connection password /// public string Password { get { return GetOptionValue("password"); } set { SetOptionValue("password", value); } } /// /// Gets or sets the connection server name /// public string ServerName { get { return GetOptionValue("server"); } set { SetOptionValue("server", value); } } /// /// Gets or sets the connection database name /// public string DatabaseName { get { return GetOptionValue("database"); } set { SetOptionValue("database", value); } } /// /// Gets or sets the connection user name /// public string UserName { get { return GetOptionValue("user"); } set { SetOptionValue("user", value); } } /// /// Gets or sets the authentication to use. /// public string AuthenticationType { get { return GetOptionValue("authenticationType"); } set { SetOptionValue("authenticationType", value); } } /// /// Gets or sets a Boolean value that indicates whether SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed. /// public bool? Encrypt { get { return GetOptionValue("encrypt"); } set { SetOptionValue("encrypt", value); } } /// /// Gets or sets a value that indicates whether the channel will be encrypted while bypassing walking the certificate chain to validate trust. /// public bool? TrustServerCertificate { get { return GetOptionValue("trustServerCertificate"); } set { SetOptionValue("trustServerCertificate", value); } } /// /// Gets or sets a Boolean value that indicates if security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state. /// public bool? PersistSecurityInfo { get { return GetOptionValue("persistSecurityInfo"); } set { SetOptionValue("persistSecurityInfo", value); } } /// /// Gets or sets the length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. /// public int? ConnectTimeout { get { return GetOptionValue("connectTimeout"); } set { SetOptionValue("connectTimeout", value); } } /// /// The number of reconnections attempted after identifying that there was an idle connection failure. /// public int? ConnectRetryCount { get { return GetOptionValue("connectRetryCount"); } set { SetOptionValue("connectRetryCount", value); } } /// /// Amount of time (in seconds) between each reconnection attempt after identifying that there was an idle connection failure. /// public int? ConnectRetryInterval { get { return GetOptionValue("connectRetryInterval"); } set { SetOptionValue("connectRetryInterval", value); } } /// /// Gets or sets the name of the application associated with the connection string. /// public string ApplicationName { get { return GetOptionValue("applicationName"); } set { SetOptionValue("applicationName", value); } } /// /// Gets or sets the name of the workstation connecting to SQL Server. /// public string WorkstationId { get { return GetOptionValue("workstationId"); } set { SetOptionValue("workstationId", value); } } /// /// Declares the application workload type when connecting to a database in an SQL Server Availability Group. /// public string ApplicationIntent { get { return GetOptionValue("applicationIntent"); } set { SetOptionValue("applicationIntent", value); } } /// /// Gets or sets the SQL Server Language record name. /// public string CurrentLanguage { get { return GetOptionValue("currentLanguage"); } set { SetOptionValue("currentLanguage", value); } } /// /// Gets or sets a Boolean value that indicates whether the connection will be pooled or explicitly opened every time that the connection is requested. /// public bool? Pooling { get { return GetOptionValue("pooling"); } set { SetOptionValue("pooling", value); } } /// /// Gets or sets the maximum number of connections allowed in the connection pool for this specific connection string. /// public int? MaxPoolSize { get { return GetOptionValue("maxPoolSize"); } set { SetOptionValue("maxPoolSize", value); } } /// /// Gets or sets the minimum number of connections allowed in the connection pool for this specific connection string. /// public int? MinPoolSize { get { return GetOptionValue("minPoolSize"); } set { SetOptionValue("minPoolSize", value); } } /// /// Gets or sets the minimum time, in seconds, for the connection to live in the connection pool before being destroyed. /// public int? LoadBalanceTimeout { get { return GetOptionValue("loadBalanceTimeout"); } set { SetOptionValue("loadBalanceTimeout", value); } } /// /// Gets or sets a Boolean value that indicates whether replication is supported using the connection. /// public bool? Replication { get { return GetOptionValue("replication"); } set { SetOptionValue("replication", value); } } /// /// Gets or sets a string that contains the name of the primary data file. This includes the full path name of an attachable database. /// public string AttachDbFilename { get { return GetOptionValue("attachDbFilename"); } set { SetOptionValue("attachDbFilename", value); } } /// /// Gets or sets the name or address of the partner server to connect to if the primary server is down. /// public string FailoverPartner { get { return GetOptionValue("failoverPartner"); } set { SetOptionValue("failoverPartner", value); } } /// /// If your application is connecting to an AlwaysOn availability group (AG) on different subnets, setting MultiSubnetFailover=true provides faster detection of and connection to the (currently) active server. /// public bool? MultiSubnetFailover { get { return GetOptionValue("multiSubnetFailover"); } set { SetOptionValue("multiSubnetFailover", value); } } /// /// When true, an application can maintain multiple active result sets (MARS). /// public bool? MultipleActiveResultSets { get { return GetOptionValue("multipleActiveResultSets"); } set { SetOptionValue("multipleActiveResultSets", value); } } /// /// Gets or sets the size in bytes of the network packets used to communicate with an instance of SQL Server. /// public int? PacketSize { get { return GetOptionValue("packetSize"); } set { SetOptionValue("packetSize", value); } } /// /// Gets or sets the port to use for the TCP/IP connection /// public int? Port { get { return GetOptionValue("port"); } set { SetOptionValue("port", value); } } /// /// Gets or sets a string value that indicates the type system the application expects. /// public string TypeSystemVersion { get { return GetOptionValue("typeSystemVersion"); } set { SetOptionValue("typeSystemVersion", value); } } /// /// Gets or sets a string value to be used as the connection string. If given, all other options will be ignored. /// public string ConnectionString { get { return GetOptionValue("connectionString"); } set { SetOptionValue("connectionString", value); } } /// /// Gets or sets the group ID /// public string GroupId { get { return GetOptionValue("groupId"); } set { SetOptionValue("groupId", value); } } /// /// Gets or sets the database display name /// public string DatabaseDisplayName { get { return GetOptionValue("databaseDisplayName"); } set { SetOptionValue("databaseDisplayName", value); } } public bool IsComparableTo(ConnectionDetails other) { if (other == null) { return false; } if (ServerName != other.ServerName || AuthenticationType != other.AuthenticationType || UserName != other.UserName) { return false; } // For database name, only compare if neither is empty. This is important // Since it allows for handling of connections to the default database, but is // not a 100% accurate heuristic. if (!string.IsNullOrEmpty(DatabaseName) && !string.IsNullOrEmpty(other.DatabaseName) && DatabaseName != other.DatabaseName) { return false; } return true; } } }