Class GuardBase
This pure abstract base class implements all interfaces of guard functions in order to provide a complete set of implementations for user-defined guard classes.
Inheritance
Namespace: TeleScope.GuardClauses.Abstractions
Assembly: TeleScope.GuardClauses.dll
Syntax
public abstract class GuardBase : object, IDefensiveGuardable, INumericGuardable, IStringGuardable, ICollectionGuardable
Methods
| Improve this Doc View SourceAll<T>(IEnumerable<T>, Func<T, Boolean>, String, String)
The implementation shall check, if all elements of the input enumeration meet a predicate function.
Declaration
public abstract IEnumerable<T> All<T>(IEnumerable<T> input, Func<T, bool> predicate, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | input | The instance under test. |
Func<T, System.Boolean> | predicate | The test function, every element must meet. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
IEnumerable<T> | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
Contains<T>(IEnumerable<T>, T, String, String)
The implementation shall check, if the input enumeration contains a specific element.
Declaration
public abstract IEnumerable<T> Contains<T>(IEnumerable<T> input, T item, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | input | The instance under test. |
T | item | The test item, used for compare opertations. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
IEnumerable<T> | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
ContainsNot<T>(IEnumerable<T>, T, String, String)
The implementation shall check, if the input enumeration doesn't contain a specific element.
Declaration
public abstract IEnumerable<T> ContainsNot<T>(IEnumerable<T> input, T item, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | input | The instance under test. |
T | item | The test item, used for compare opertations. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
IEnumerable<T> | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
Equality<T>(T, T, String, String)
The implementation shall check the input against an equal comparator and fail, if both instances are equal.
Declaration
public abstract T Equality<T>(T input, T comparator, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
T | input | The instance under test. |
T | comparator | The instance that shall be compared by an implementation of the method. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
T | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
False(Boolean, String, String)
The implementation shall check the boolean input against False
and fail, if that is the case.
Declaration
public abstract bool False(bool input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
System.Boolean | The input data, if no exception will be thrown. |
IsExact<T>(T, T, String, String)
The implementation shall check, if the input number has exactly the same value of the comparator.
Declaration
public abstract T IsExact<T>(T input, T comparator, string expression = null, string message = null)
where T : IComparable
Parameters
Type | Name | Description |
---|---|---|
T | input | The instance under test. |
T | comparator | The instance that shall be compared by an implementation of the method. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
T | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
IsFilled<T>(IEnumerable<T>, String, String)
The implementation shall check, if all elements of the input enumeration are not null.
Declaration
public abstract IEnumerable<T> IsFilled<T>(IEnumerable<T> input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
IEnumerable<T> | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
IsIpAddress(String, InternetProtocols, String, String)
The implementation shall check, if the input string is a valid IP address.
Declaration
public abstract string IsIpAddress(string input, InternetProtocols protocol = InternetProtocols.IPv4, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The instance under test. |
InternetProtocols | protocol | The protocol version that needs to match during the guard precedure. The default value is IPv4. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
System.String | The input data, if no exception will be thrown. |
IsLarger<T>(T, T, String, String)
The implementation shall check, if the input number is larger than the comparator.
Declaration
public abstract T IsLarger<T>(T input, T comparator, string expression = null, string message = null)
where T : IComparable
Parameters
Type | Name | Description |
---|---|---|
T | input | The instance under test. |
T | comparator | The instance that shall be compared by an implementation of the method. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
T | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
IsLargerThanZero<T>(T, String, String)
The implementation shall check, if the input number is larger than zero.
Declaration
public abstract T IsLargerThanZero<T>(T input, string expression = null, string message = null)
where T : IComparable
Parameters
Type | Name | Description |
---|---|---|
T | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
T | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
IsMailAddress(String, String, String)
The implementation shall check, if the input string is a valid email address.
Declaration
public abstract string IsMailAddress(string input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
System.String | The input data, if no exception will be thrown. |
IsNot<T>(T, String, String, T[])
The implementation shall check, if the input number has not the same value of the comparator.
Declaration
public abstract T IsNot<T>(T input, string expression = null, string message = null, params T[] comparators)
where T : IComparable
Parameters
Type | Name | Description |
---|---|---|
T | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
T[] | comparators | The potential multiple instance that shall be compared by an implementation of the method. |
Returns
Type | Description |
---|---|
T | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
IsNotEmpty<T>(IEnumerable<T>, String, String)
The implementation shall check, if the input enumeration is not empty.
Declaration
public abstract IEnumerable<T> IsNotEmpty<T>(IEnumerable<T> input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
IEnumerable<T> | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
IsNotNullOrEmpty(String, String, String)
The implementation shall check, if the input string is Null or an empty string.
Declaration
public abstract string IsNotNullOrEmpty(string input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
System.String | The input data, if no exception will be thrown. |
IsNotNullOrWhiteSpace(String, String, String)
The implementation shall check, if the input string is Null or a whitespace.
Declaration
public abstract string IsNotNullOrWhiteSpace(string input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
System.String | The input data, if no exception will be thrown. |
IsNotZero<T>(T, String, String)
The implementation shall check, if the input number is not zero.
Declaration
public abstract T IsNotZero<T>(T input, string expression = null, string message = null)
where T : IComparable
Parameters
Type | Name | Description |
---|---|---|
T | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
T | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
IsSmaller<T>(T, T, String, String)
The implementation shall check, if the input number is smaller than the comparator.
Declaration
public abstract T IsSmaller<T>(T input, T comparator, string expression = null, string message = null)
where T : IComparable
Parameters
Type | Name | Description |
---|---|---|
T | input | The instance under test. |
T | comparator | The instance that shall be compared by an implementation of the method. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
T | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
IsUri(String, UriKind, String, String)
The implementation shall check, if the input string is a valid Uri.
Declaration
public abstract string IsUri(string input, UriKind kind = null, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The instance under test. |
UriKind | kind | The uri kind. The default value is |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
System.String | The input data, if no exception will be thrown. |
IsWebUri(String, String, String)
The implementation shall check, if the input string is a valid Uri.
Declaration
public abstract string IsWebUri(string input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
System.String | The input data, if no exception will be thrown. |
Null<T>(T, String, String)
The implementation shall check the input against null and fail, if that is the case.
Declaration
public abstract T Null<T>(T input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
T | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
T | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |
ToMailAddress(String, String, String)
The implementation shall check, if the input string is a valid email address.
Declaration
public abstract MailAddress ToMailAddress(string input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
MailAddress | The input data as |
ToUri(String, String, String)
The implementation shall check, if the input string is a valid Uri and
shall convert the value into an
Declaration
public abstract Uri ToUri(string input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
Uri | The input data, if no exception will be thrown. |
True(Boolean, String, String)
The implementation shall check the boolean input against True
and fail, if that is the case.
Declaration
public abstract bool True(bool input, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | input | The instance under test. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
System.Boolean | The input data, if no exception will be thrown. |
Unequality<T>(T, T, String, String)
The implementation shall check the input against an unequal comparator and fail, if both instances are unequal.
Declaration
public abstract T Unequality<T>(T input, T comparator, string expression = null, string message = null)
Parameters
Type | Name | Description |
---|---|---|
T | input | The instance under test. |
T | comparator | The instance that shall be compared by an implementation of the method. |
System.String | expression | The optional parameter name under test. |
System.String | message | The optional exception message that wil be used, if the method implementation throws. |
Returns
Type | Description |
---|---|
T | The input data, if no exception will be thrown. |
Type Parameters
Name | Description |
---|---|
T | The type param under test. |