mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-18 01:25:41 -05:00
Fixed node labels, status, sub types (#338)
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Globalization;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom name for parameters
|
||||
/// </summary>
|
||||
internal partial class TableValuedFunctionParametersChildFactory : SmoChildFactoryBase
|
||||
{
|
||||
public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.CalculateCustomLabel(smoObject, smoContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom name for parameters
|
||||
/// </summary>
|
||||
internal partial class ScalarValuedFunctionParametersChildFactory : SmoChildFactoryBase
|
||||
{
|
||||
public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.CalculateCustomLabel(smoObject, smoContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom name for parameters
|
||||
/// </summary>
|
||||
internal partial class AggregateFunctionParametersChildFactory : SmoChildFactoryBase
|
||||
{
|
||||
public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.CalculateCustomLabel(smoObject, smoContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom name for parameters
|
||||
/// </summary>
|
||||
internal partial class StoredProcedureParametersChildFactory : SmoChildFactoryBase
|
||||
{
|
||||
public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.CalculateCustomLabel(smoObject, smoContext);
|
||||
}
|
||||
}
|
||||
|
||||
static class ParameterCustomeNodeHelper
|
||||
{
|
||||
|
||||
internal static string CalculateCustomLabel(object context, SmoQueryContext smoContext)
|
||||
{
|
||||
Parameter parameter = context as Parameter;
|
||||
if (parameter != null)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.GetParameterCustomLabel(parameter);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
internal static string GetParameterCustomLabel(Parameter parameter)
|
||||
{
|
||||
string label = parameter.Name;
|
||||
string defaultString = SR.SchemaHierarchy_SubroutineParameterNoDefaultLabel;
|
||||
string inputOutputString = SR.SchemaHierarchy_SubroutineParameterInputLabel;
|
||||
string typeName = parameter.DataType.ToString();
|
||||
|
||||
if (parameter.DefaultValue != null &&
|
||||
!string.IsNullOrEmpty(parameter.DefaultValue))
|
||||
{
|
||||
defaultString = SR.SchemaHierarchy_SubroutineParameterDefaultLabel;
|
||||
}
|
||||
|
||||
StoredProcedureParameter stordProcedureParameter = parameter as StoredProcedureParameter;
|
||||
if (stordProcedureParameter != null && stordProcedureParameter.IsOutputParameter)
|
||||
{
|
||||
inputOutputString = SR.SchemaHierarchy_SubroutineParameterInputOutputLabel;
|
||||
if (parameter.IsReadOnly)
|
||||
{
|
||||
inputOutputString = SR.SchemaHierarchy_SubroutineParameterInputOutputReadOnlyLabel;
|
||||
}
|
||||
}
|
||||
else if (parameter.IsReadOnly)
|
||||
{
|
||||
inputOutputString = SR.SchemaHierarchy_SubroutineParameterInputReadOnlyLabel;
|
||||
}
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture,
|
||||
SR.SchemaHierarchy_SubroutineParameterLabelFormatString,
|
||||
label,
|
||||
typeName,
|
||||
inputOutputString,
|
||||
defaultString);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user