187 lines
5.8 KiB
XML
187 lines
5.8 KiB
XML
<chapter id="misc">
|
|
<title>Spring.NET miscellanea</title>
|
|
<sect1>
|
|
<title>Introduction</title>
|
|
<para>
|
|
This chapter contains miscellanea information on features, goodies, caveats
|
|
that does not belong to any paricular area.
|
|
</para>
|
|
</sect1>
|
|
<sect1>
|
|
<title>PathMatcher</title>
|
|
<para>
|
|
<emphasis>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
|
|
<ulink url="http://opensource.atlassian.com/confluence/spring/display/NET/Project+Structure">(instructions)</ulink>
|
|
or from the download section of the
|
|
Spring.NET website that contains an .zip with the full CVS tree.
|
|
</emphasis>
|
|
</para>
|
|
<para>
|
|
<literal>Spring.Util.PathMatcher</literal> provides <literal>Ant/NAnt</literal>-like path name matching
|
|
features.
|
|
</para>
|
|
<para>To do the match, you use the method:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
tatic bool Match(string pattern, string path)</programlisting>
|
|
</para>
|
|
<para>If you want to decide if case is important or not use the method:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
tatic bool Match(string pattern, string path, bool ignoreCase)</programlisting>
|
|
</para>
|
|
<sect2>
|
|
<title>General rules</title>
|
|
<para>
|
|
To build your pattern, you use the <literal>*</literal>, <literal>?</literal>
|
|
and <literal>**</literal> building blocks:
|
|
<itemizedlist spacing="compact">
|
|
<listitem>
|
|
<para><literal>*</literal>: matches any number of non slash
|
|
characters;
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para><literal>?</literal>: matches exactly 1 (one) non slash/dot
|
|
character;
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para><literal>**</literal>: matches any subdirectory, without
|
|
taking care of the depth;
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>Matching filenames</title>
|
|
<para>
|
|
A file name can be matched using the following
|
|
notation:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
foo?bar.*</programlisting>
|
|
matches:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
fooAbar.txt
|
|
foo1bar.txt
|
|
foo_bar.txt
|
|
foo-bar.txt</programlisting>
|
|
does not match:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
foo.bar.txt
|
|
foo/bar.txt
|
|
foo\bar.txt</programlisting>
|
|
</para>
|
|
<para>
|
|
The classical all files pattern:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
*.*</programlisting>
|
|
matches:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
foo.db
|
|
.db
|
|
foo
|
|
foo.bar.db
|
|
foo.db.db
|
|
db.db.db</programlisting>
|
|
does not match:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
c:/
|
|
c:/foo.db
|
|
c:/foo
|
|
c:/.db
|
|
c:/foo.foo.db
|
|
//server/foo</programlisting>
|
|
</para>
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>Matching subdirectories</title>
|
|
<para>
|
|
A directory name can be matched at any depth level using the following
|
|
notation:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
**/db/**</programlisting>
|
|
That pattern matches the following paths:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
/db
|
|
//server/db
|
|
c:/db
|
|
c:/spring/app/db/foo.db
|
|
//Program Files/App/spaced dir/db/foo.db
|
|
/home/spring/spaced dir/db/v1/foo.db</programlisting>
|
|
but does not match these:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
c:/spring/app/db-v1/foo.db
|
|
/home/spring/spaced dir/db-v1/foo.db</programlisting>
|
|
</para>
|
|
<para>
|
|
You can compose subdirectories to match like this:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
**/bin/**/tmp/**</programlisting>
|
|
That pattern matches the following paths:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
c:/spring/foo/bin/bar/tmp/a
|
|
c:/spring/foo/bin/tmp/a/b.c</programlisting>
|
|
but does not match these:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
c:/spring/foo/bin/bar/temp/a
|
|
c:/tmp/foo/bin/bar/a/b.c</programlisting>
|
|
</para>
|
|
<para>
|
|
You can use more advanced patterns:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
**/.spring-assemblies*/**</programlisting>
|
|
matches:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
c:/.spring-assemblies
|
|
c:/.spring-assembliesabcd73xs
|
|
c:/app/.spring-assembliesabcd73xs
|
|
c:/app/.spring-assembliesabcd73xs/foo.dll
|
|
//server/app/.spring-assembliesabcd73xs</programlisting>
|
|
does not match:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
c:/app/.spring-assemblie</programlisting>
|
|
</para>
|
|
</sect2>
|
|
|
|
<sect2>
|
|
<title>Case does matter, slashes don't</title>
|
|
<para>
|
|
.NET is expected to be a cross-platform development ... platform. So,
|
|
<literal>PathMatcher</literal> will match taking care of the case of the pattern
|
|
and the case of the path. For example:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
**/db/**/*.DB</programlisting>
|
|
matches:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
c:/spring/service/deploy/app/db/foo.DB</programlisting>
|
|
but does not match:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
c:/spring/service/deploy/app/DB/foo.DB
|
|
c:spring/service/deploy/app/spaced dir/DB/foo.DB
|
|
//server/share/service/deploy/app/DB/backup/foo.db</programlisting>
|
|
</para>
|
|
<para>If you do not matter about case, you should explicitly tell the
|
|
<literal>Pathmatcher</literal>.</para>
|
|
<para>
|
|
Back and forward slashes, in the very same cross-platform spirit, are
|
|
not important:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
spring/foo.bar</programlisting>
|
|
matches all the following paths:
|
|
<programlisting format='linespecific' xml:space='preserve'>
|
|
c:\spring\foo.bar
|
|
c:/spring\foo.bar
|
|
c:/spring/foo.bar
|
|
/spring/foo.bar
|
|
\spring\foo.bar</programlisting>
|
|
</para>
|
|
</sect2>
|
|
|
|
</sect1>
|
|
|
|
</chapter>
|