Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit b548e6a

Browse files
committed
moved ApplicationRealiveMatchingStrategy into main project
1 parent fcc2815 commit b548e6a

3 files changed

Lines changed: 29 additions & 24 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.IO;
3+
using System.Text.RegularExpressions;
4+
5+
namespace CassetteHelper
6+
{
7+
public class ApplicationRelativeMatchingStrategy : IMatchingStrategy
8+
{
9+
private readonly Regex matchingRegex;
10+
11+
public ApplicationRelativeMatchingStrategy(string applicationRootDirectory, string originalFilePath)
12+
{
13+
if (String.IsNullOrEmpty(applicationRootDirectory)) throw new ArgumentNullException("applicationRootDirectory");
14+
if (String.IsNullOrEmpty(originalFilePath)) throw new ArgumentNullException("originalFilePath");
15+
16+
if (!Directory.Exists(applicationRootDirectory)) throw new ArgumentException("Could not find directory '" + applicationRootDirectory + "'", "applicationRootDirectory");
17+
18+
var applicationRelativePath = originalFilePath.URIRelativeTo(applicationRootDirectory);
19+
this.matchingRegex = new Regex("^\\W*///\\W*<reference\\W+path=\"~/" + applicationRelativePath + "\"\\W*/>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
20+
//this.matchingRegex = new Regex("^///\\W+<reference path=\"~/(?<path>[^\"]+)\"\\W+/>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
21+
}
22+
23+
public bool Match(string line)
24+
{
25+
return !String.IsNullOrWhiteSpace(line) && matchingRegex.IsMatch(line);
26+
}
27+
}
28+
}

‎CassetteHelper/CassetteHelper.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<Reference Include="Microsoft.CSharp" />
4949
</ItemGroup>
5050
<ItemGroup>
51+
<Compile Include="ApplicationRelativeMatchingStrategy.cs" />
5152
<Compile Include="AssemblyInfo.cs">
5253
<SubType>Code</SubType>
5354
</Compile>

‎CassetteHelperTests/ApplicationRelativeMatchingStrategyTests.cs‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.IO;
3-
using System.Text.RegularExpressions;
42
using CassetteHelper;
53
using MbUnit.Framework;
64

@@ -46,26 +44,4 @@ public void Match(string line, bool expected)
4644
Assert.AreEqual(expected, strategy.Match(line));
4745
}
4846
}
49-
50-
public class ApplicationRelativeMatchingStrategy : IMatchingStrategy
51-
{
52-
private readonly Regex matchingRegex;
53-
54-
public ApplicationRelativeMatchingStrategy(string applicationRootDirectory, string originalFilePath)
55-
{
56-
if (String.IsNullOrEmpty(applicationRootDirectory)) throw new ArgumentNullException("applicationRootDirectory");
57-
if (String.IsNullOrEmpty(originalFilePath)) throw new ArgumentNullException("originalFilePath");
58-
59-
if (!Directory.Exists(applicationRootDirectory)) throw new ArgumentException("Could not find directory '" + applicationRootDirectory + "'", "applicationRootDirectory");
60-
61-
var applicationRelativePath = originalFilePath.URIRelativeTo(applicationRootDirectory);
62-
this.matchingRegex = new Regex("^\\W*///\\W*<reference\\W+path=\"~/" + applicationRelativePath + "\"\\W*/>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
63-
//this.matchingRegex = new Regex("^///\\W+<reference path=\"~/(?<path>[^\"]+)\"\\W+/>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
64-
}
65-
66-
public bool Match(string line)
67-
{
68-
return !String.IsNullOrWhiteSpace(line) && matchingRegex.IsMatch(line);
69-
}
70-
}
7147
}

0 commit comments

Comments
 (0)