Class Mandate
Helper class for mandating values, for example on method parameters.
Inheritance
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public static class Mandate
Methods
ParameterCondition(Boolean, String)
Mandates that the specified parameter matches the condition.
Declaration
public static void ParameterCondition(bool condition, string paramName)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | condition | The condition to check. |
System.String | paramName | Name of the param. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If the condition is false. |
ParameterCondition(Boolean, String, String)
Mandates that the specified parameter matches the condition.
Declaration
public static void ParameterCondition(bool condition, string paramName, string message)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | condition | The condition to check. |
System.String | paramName | Name of the param. |
System.String | message | The message. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If the condition is false. |
ParameterNotNull<T>(T, String)
Mandates that the specified parameter is not null.
Declaration
public static void ParameterNotNull<T>(T value, string paramName)where T : class
Parameters
Type | Name | Description |
---|---|---|
T | value | The value. |
System.String | paramName | Name of the param. |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If value is null. |
ParameterNotNullOrEmpty(String, String)
Mandates that the specified parameter is not null.
Declaration
public static void ParameterNotNullOrEmpty(string value, string paramName)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value. |
System.String | paramName | Name of the param. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If value is null or whitespace. |
ParameterNotNullOrEmpty<T>(IEnumerable<T>, String)
Mandates that the specified sequence is not null and has at least one element.
Declaration
public static void ParameterNotNullOrEmpty<T>(IEnumerable<T> sequence, string paramName)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | sequence | The sequence. |
System.String | paramName | Name of the param. |
Type Parameters
Name | Description |
---|---|
T |
That<TException>(Boolean)
Mandates that the specified condition is true, otherwise throws an exception specified in TException.
Declaration
public static void That<TException>(bool condition)where TException : Exception, new ()
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | condition | if set to |
Type Parameters
Name | Description |
---|---|
TException | The type of the exception. |
Exceptions
Type | Condition |
---|---|
System.Exception | An exception of type TException is raised if the condition is false. |
That<TException>(Boolean, Func<TException>)
Mandates that the specified condition is true, otherwise throws an exception specified in TException.
Declaration
public static void That<TException>(bool condition, Func<TException> defer)where TException : Exception, new ()
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | condition | if set to |
System.Func<TException> | defer | Deffered expression to call if the exception should be raised. |
Type Parameters
Name | Description |
---|---|
TException | The type of the exception. |
Exceptions
Type | Condition |
---|---|
System.Exception | An exception of type TException is raised if the condition is false. |