Class Requires
Provides contract checks.
Inheritance
Inherited Members
Namespace: Kephas.Diagnostics.Contracts
Assembly: Kephas.Core.dll
Syntax
public static class Requires
Methods
| Improve this Doc View SourceNotNull<T>(T, String)
Requires that the argument is not null.
Declaration
[ContractArgumentValidator]
public static void NotNull<T>(T value, string parameterName)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T | value | The value. |
System.String | parameterName | Name of the parameter. |
Type Parameters
Name | Description |
---|---|
T | The argument type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when the required argument is null. |
NotNull<T>(Nullable<T>, String)
Requires that the argument is not null.
Declaration
[ContractArgumentValidator]
public static void NotNull<T>(T? value, string parameterName)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<T> | value | The value. |
System.String | parameterName | Name of the parameter. |
Type Parameters
Name | Description |
---|---|
T | The argument type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when the required argument is null. |
NotNullOrEmpty(String, String)
Requires that the argument is not null or empty.
Declaration
[ContractArgumentValidator]
public static void NotNullOrEmpty(string value, string parameterName)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value. |
System.String | parameterName | Name of the parameter. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when the required argument is null or empty. |
NotNullOrEmpty<T>(T[], String)
Requires that the argument is not null or empty.
Declaration
[ContractArgumentValidator]
public static void NotNullOrEmpty<T>(T[] value, string parameterName)
Parameters
Type | Name | Description |
---|---|---|
T[] | value | The value. |
System.String | parameterName | Name of the parameter. |
Type Parameters
Name | Description |
---|---|
T | The argument type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when the required argument is null. |
System.ArgumentException | Thrown when the required argument is empty. |
NotNullOrEmpty<T>(ICollection<T>, String)
Requires that the argument is not null or empty.
Declaration
[ContractArgumentValidator]
public static void NotNullOrEmpty<T>(ICollection<T> value, string parameterName)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.ICollection<T> | value | The value. |
System.String | parameterName | Name of the parameter. |
Type Parameters
Name | Description |
---|---|
T | The array item type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when the required argument is null. |
System.ArgumentException | Thrown when the required argument is empty. |
NotNullOrEmpty<T>(IEnumerable<T>, String)
Requires that the argument is not null or empty.
Declaration
[ContractArgumentValidator]
public static void NotNullOrEmpty<T>(IEnumerable<T> value, string parameterName)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | value | The value. |
System.String | parameterName | Name of the parameter. |
Type Parameters
Name | Description |
---|---|
T | The array item type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when the required argument is null. |
System.ArgumentException | Thrown when the required argument is empty. |