mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
* Move unused forked code to external directory * Fix SLN build errors * Add back resource provider core since it's referenced by main resource provider project * Update PackageProjects step of pipeline
51 lines
1.9 KiB
C#
51 lines
1.9 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
//
|
|
|
|
using Microsoft.SqlTools.DataProtocol.Contracts.Connection;
|
|
|
|
namespace Microsoft.SqlTools.CoreServices.Connection
|
|
{
|
|
/// <summary>
|
|
/// Extension methods to ConnectParams
|
|
/// </summary>
|
|
public static class ConnectParamsExtensions
|
|
{
|
|
/// <summary>
|
|
/// Check that the fields in ConnectParams are all valid
|
|
/// </summary>
|
|
public static bool IsValid(this ConnectParams parameters, out string errorMessage)
|
|
{
|
|
errorMessage = string.Empty;
|
|
if (string.IsNullOrEmpty(parameters.OwnerUri))
|
|
{
|
|
errorMessage = SR.ConnectionParamsValidateNullOwnerUri;
|
|
}
|
|
else if (parameters.Connection == null)
|
|
{
|
|
errorMessage = SR.ConnectionParamsValidateNullConnection;
|
|
}
|
|
else if (!string.IsNullOrEmpty(parameters.Connection.ConnectionString))
|
|
{
|
|
// Do not check other connection parameters if a connection string is present
|
|
return string.IsNullOrEmpty(errorMessage);
|
|
}
|
|
else if (string.IsNullOrEmpty(parameters.Connection.ServerName))
|
|
{
|
|
errorMessage = SR.ConnectionParamsValidateNullServerName;
|
|
}
|
|
else if (string.IsNullOrEmpty(parameters.Connection.AuthenticationType) || parameters.Connection.AuthenticationType == "SqlLogin")
|
|
{
|
|
// For SqlLogin, username cannot be empty
|
|
if (string.IsNullOrEmpty(parameters.Connection.UserName))
|
|
{
|
|
errorMessage = SR.ConnectionParamsValidateNullSqlAuth("UserName");
|
|
}
|
|
}
|
|
|
|
return string.IsNullOrEmpty(errorMessage);
|
|
}
|
|
}
|
|
}
|