Browse Source

Refactor TextTemplatingVariables class.

pull/23/head
Matt Ward 15 years ago
parent
commit
092b913bfb
  1. 2
      src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingVariables.cs
  2. 2
      src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHost.cs
  3. 2
      src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingPathResolver.cs
  4. 2
      src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariables.cs
  5. 2
      src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingVariables.cs
  6. 12
      src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingVariablesTests.cs

2
src/AddIns/Misc/TextTemplating/Project/Src/ITextTemplatingVariables.cs

@ -7,7 +7,7 @@ namespace ICSharpCode.TextTemplating
{ {
public interface ITextTemplatingVariables public interface ITextTemplatingVariables
{ {
string Expand(string name); string ExpandVariables(string name);
string GetValue(string name); string GetValue(string name);
} }
} }

2
src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingHost.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.TextTemplating
string ExpandPath(string path) string ExpandPath(string path)
{ {
return templatingVariables.Expand(path); return templatingVariables.ExpandVariables(path);
} }
} }
} }

2
src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingPathResolver.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.TextTemplating
public string ResolvePath(string path) public string ResolvePath(string path)
{ {
path = environment.ExpandEnvironmentVariables(path); path = environment.ExpandEnvironmentVariables(path);
return templatingVariables.Expand(path); return templatingVariables.ExpandVariables(path);
} }
} }
} }

2
src/AddIns/Misc/TextTemplating/Project/Src/TextTemplatingVariables.cs

@ -23,7 +23,7 @@ namespace ICSharpCode.TextTemplating
this.stringParser = stringParser; this.stringParser = stringParser;
} }
public string Expand(string name) public string ExpandVariables(string name)
{ {
var variablesBuilder = new TextTemplatingVariablesStringBuilder(name, this); var variablesBuilder = new TextTemplatingVariablesStringBuilder(name, this);
foreach (TextTemplatingVariableLocation variableLocation in GetVariables(name)) { foreach (TextTemplatingVariableLocation variableLocation in GetVariables(name)) {

2
src/AddIns/Misc/TextTemplating/Test/Helpers/FakeTextTemplatingVariables.cs

@ -17,7 +17,7 @@ namespace TextTemplating.Tests.Helpers
Variables.Add(name, value); Variables.Add(name, value);
} }
public string Expand(string name) public string ExpandVariables(string name)
{ {
foreach (KeyValuePair<string, string> variable in Variables) { foreach (KeyValuePair<string, string> variable in Variables) {
name = name.Replace(variable.Key, variable.Value); name = name.Replace(variable.Key, variable.Value);

12
src/AddIns/Misc/TextTemplating/Test/Src/TextTemplatingVariablesTests.cs

@ -28,24 +28,24 @@ namespace TextTemplating.Tests
} }
[Test] [Test]
public void Expand_SolutionDirProperty_SolutionDirPropertyIsExpanded() public void ExpandVariables_SolutionDirProperty_SolutionDirPropertyIsExpanded()
{ {
CreateTextTemplatingVariables(); CreateTextTemplatingVariables();
AddProperty("SolutionDir", @"d:\projects\MyProject\"); AddProperty("SolutionDir", @"d:\projects\MyProject\");
string result = variables.Expand(@"$(SolutionDir)bin\Debug\Test.dll"); string result = variables.ExpandVariables(@"$(SolutionDir)bin\Debug\Test.dll");
string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll"; string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll";
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);
} }
[Test] [Test]
public void Expand_ProjectDirProperty_ProjectDirPropertyIsExpanded() public void ExpandVariables_ProjectDirProperty_ProjectDirPropertyIsExpanded()
{ {
CreateTextTemplatingVariables(); CreateTextTemplatingVariables();
AddProperty("ProjectDir", @"d:\projects\MyProject\"); AddProperty("ProjectDir", @"d:\projects\MyProject\");
string result = variables.Expand(@"$(ProjectDir)bin\Debug\Test.dll"); string result = variables.ExpandVariables(@"$(ProjectDir)bin\Debug\Test.dll");
string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll"; string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll";
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);
@ -227,12 +227,12 @@ namespace TextTemplating.Tests
} }
[Test] [Test]
public void Expand_ProjectDirPropertyHasNoTrailingSlash_ProjectDirPropertyIsExpandedWithTrailingSlash() public void ExpandVariables_ProjectDirPropertyHasNoTrailingSlash_ProjectDirPropertyIsExpandedWithTrailingSlash()
{ {
CreateTextTemplatingVariables(); CreateTextTemplatingVariables();
AddProperty("ProjectDir", @"d:\projects\MyProject"); AddProperty("ProjectDir", @"d:\projects\MyProject");
string result = variables.Expand(@"$(ProjectDir)bin\Debug\Test.dll"); string result = variables.ExpandVariables(@"$(ProjectDir)bin\Debug\Test.dll");
string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll"; string expectedResult = @"d:\projects\MyProject\bin\Debug\Test.dll";
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);

Loading…
Cancel
Save