mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 09:35:43 -05:00
* Created New ManagedBatchParser project in .NetStandard * Addressing PR Comments * Resolve 'No Repository' warning. * Move batch parser tests to integrations test project * Fix SLN file
49 lines
1.3 KiB
C#
49 lines
1.3 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 System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Microsoft.SqlTools.ServiceLayer.BatchParser;
|
|
|
|
namespace Microsoft.SqlTools.ManagedBatchParser.UnitTests.BatchParser
|
|
{
|
|
internal sealed class TestVariableResolver : IVariableResolver
|
|
{
|
|
Dictionary<string, string> variables = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
|
private StringBuilder outputString;
|
|
|
|
public TestVariableResolver(StringBuilder outputString)
|
|
{
|
|
this.outputString = outputString;
|
|
}
|
|
|
|
public string GetVariable(PositionStruct pos, string name)
|
|
{
|
|
if (variables.ContainsKey(name))
|
|
{
|
|
return variables[name];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public void SetVariable(PositionStruct pos, string name, string value)
|
|
{
|
|
outputString.AppendFormat("Setting variable {0} to [{1}]\n", name, value);
|
|
if (value == null)
|
|
{
|
|
variables.Remove(name);
|
|
}
|
|
else
|
|
{
|
|
variables[name] = value;
|
|
}
|
|
}
|
|
}
|
|
}
|