<%@ CodeTemplate %> <%@ Import Namespace="System.IO" %> <%@ Assembly Name="AgileDocs.Core" %> <%@ Import Namespace="AgileDocs.Core" %>

string Example(string example, string what) { return "

    "
          + XmlPeek.HtmlEncode (
    			XmlPeek.ExtractAndQueryXPath(
    				Path.Combine("test/Spring/Spring.Core.Tests/Data/PathMatcher", "Examples.test"),
    				String.Format("examples/example[@name='{0}']/{1}", example, what),
    				new ExtractXml("#", null)))
          + "

"; }

# Spring.NET miscellanea

## Introduction

This chapter contains miscellanea information on features, goodies, caveats that does not belong to any paricular area.

## PathMatcher

Note, Spring.Util.PathMatcher is currently only available in CVS, not the RC3 release. If you want to use these feature please get the code from CVS (instructions) or from the download section of the Spring.NET website that contains an .zip with the full CVS tree.

`Spring.Util.PathMatcher` provides `Ant/NAnt`-like path name matching features.

To do the match, you use the method:

    <%=
    	  XmlPeek.HtmlEncode (
    			XmlPeek.ExtractAndQueryXPath(
    				"src/Spring/Spring.Core/Util/PathMatcher.cs",
    				"fragments/fragment[@name='match-method']"))
       %>

If you want to decide if case is important or not use the method:

    <%=
    	  XmlPeek.HtmlEncode (
    			XmlPeek.ExtractAndQueryXPath(
    				"src/Spring/Spring.Core/Util/PathMatcher.cs",
    				"fragments/fragment[@name='match-method-nocase']"))
       %>

### General rules

To build your pattern, you use the `*`, `?` and `**` building blocks:

- `*`: matches any number of non slash characters;

- `?`: matches exactly 1 (one) non slash/dot character;

- `**`: matches any subdirectory, without taking care of the depth;

### Matching filenames

A file name can be matched using the following notation: <%= Example("filename", "pattern") %> matches: <%= Example("filename", "match") %> does not match: <%= Example("filename", "dont.match") %>

The classical all files pattern: <%= Example("filename-all", "pattern") %> matches: <%= Example("filename-all", "match") %> does not match: <%= Example("filename-all", "dont.match") %>

### Matching subdirectories

A directory name can be matched at any depth level using the following notation: <%= Example("subdir", "pattern") %> That pattern matches the following paths: <%= Example("subdir", "match") %> but does not match these: <%= Example("subdir", "dont.match") %>

You can compose subdirectories to match like this: <%= Example("double-subdir", "pattern") %> That pattern matches the following paths: <%= Example("double-subdir", "match") %> but does not match these: <%= Example("double-subdir", "dont.match") %>

You can use more advanced patterns: <%= Example("subdir-2", "pattern") %> matches: <%= Example("subdir-2", "match") %> does not match: <%= Example("subdir-2", "dont.match") %>

### Case does matter, slashes don't

.NET is expected to be a cross-platform development ... platform. So, `PathMatcher` will match taking care of the case of the pattern and the case of the path. For example: <%= Example("case-sensitive", "pattern") %> matches: <%= Example("case-sensitive", "match") %> but does not match: <%= Example("case-sensitive", "dont.match") %>

If you do not matter about case, you should explicitly tell the `Pathmatcher`.

Back and forward slashes, in the very same cross-platform spirit, are not important: <%= Example("slashes", "pattern") %> matches all the following paths: <%= Example("slashes", "match") %>