Class NameFilter
NameFilter is a string matching class which allows for both positive and negative matching. A filter is a sequence of independant System.Text.RegularExpressions.Regex separated by semi-colons ';'. To include a semi-colon it may be quoted as in ;. Each expression can be prefixed by a plus '+' sign or a minus '-' sign to denote the expression is intended to include or exclude names. If neither a plus or minus sign is found include is the default. A given name is tested for inclusion before checking exclusions. Only names matching an include spec and not matching an exclude spec are deemed to match the filter. An empty filter matches any name.
Inheritance
Implements
Inherited Members
Namespace: ICSharpCode.SharpZipLib.Core
Assembly: ICSharpCode.SharpZipLib.dll
Syntax
public class NameFilter : IScanFilter
Examples
The following expression includes all name ending in '.dat' with the exception of 'dummy.dat' "+.dat$;-^dummy.dat$"
Constructors
| Improve this Doc View SourceNameFilter(String)
Construct an instance based on the filter expression passed
Declaration
public NameFilter(string filter)
Parameters
Type | Name | Description |
---|---|---|
System.String | filter | The filter expression. |
Methods
| Improve this Doc View SourceIsExcluded(String)
Test a value to see if it is excluded by the filter.
Declaration
public bool IsExcluded(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The value to test. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value is excluded, false otherwise. |
IsIncluded(String)
Test a value to see if it is included by the filter.
Declaration
public bool IsIncluded(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The value to test. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value is included, false otherwise. |
IsMatch(String)
Test a value to see if it matches the filter.
Declaration
public bool IsMatch(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The value to test. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value matches, false otherwise. |
IsValidExpression(String)
Test a string to see if it is a valid regular expression.
Declaration
public static bool IsValidExpression(string expression)
Parameters
Type | Name | Description |
---|---|---|
System.String | expression | The expression to test. |
Returns
Type | Description |
---|---|
System.Boolean | True if expression is a valid System.Text.RegularExpressions.Regex false otherwise. |
IsValidFilterExpression(String)
Test an expression to see if it is valid as a filter.
Declaration
public static bool IsValidFilterExpression(string toTest)
Parameters
Type | Name | Description |
---|---|---|
System.String | toTest | The filter expression to test. |
Returns
Type | Description |
---|---|
System.Boolean | True if the expression is valid, false otherwise. |
SplitQuoted(String)
Split a string into its component pieces
Declaration
public static string[] SplitQuoted(string original)
Parameters
Type | Name | Description |
---|---|---|
System.String | original | The original string |
Returns
Type | Description |
---|---|
System.String[] | Returns an array of System.String values containing the individual filter elements. |
ToString()
Convert this filter to its string equivalent.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | The string equivalent for this filter. |