Show / Hide Table of Contents

Class BooleanEx

Class containing some extension methods for System.Boolean.

Inheritance
System.Object
BooleanEx
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace:Extend
Assembly:Extend.dll
Syntax
public static class BooleanEx

Methods

| Improve this Doc View Source

IfFalse(Boolean, Action, Action)

Executes the specified action if the given Boolean is false, otherwise it executes the specified alternative action, if one is specified.

Declaration
public static bool IfFalse(this bool value, Action action, Action alternativeAction = null)
Parameters
Type Name Description
System.Boolean value

The Boolean to check.

System.Action action

The action to execute if the given value is false.

System.Action alternativeAction

The action to execute if the given value is true.>

Returns
Type Description
System.Boolean

Returns the given boolean value.

Exceptions
Type Condition
System.ArgumentNullException

action can not be null.

| Improve this Doc View Source

IfFalse<T>(Boolean, T, Action<T>, Action<T>)

Executes the specified action if the given Boolean is false, otherwise it executes the specified alternative action, if one is specified.

Declaration
public static bool IfFalse<T>(this bool value, T parameter, Action<T> action, Action<T> alternativeAction = null)
Parameters
Type Name Description
System.Boolean value

The Boolean to check.

T parameter

The parameter to pass to the action with gets executed.

System.Action<T><T> action

The action to execute if the given value is false.

System.Action<T><T> alternativeAction

The action to execute if the given value is true.>

Returns
Type Description
System.Boolean

Returns the given boolean value.

Type Parameters
Name Description
T The type of the parameter.
Exceptions
Type Condition
System.ArgumentNullException

action can not be null.

| Improve this Doc View Source

IfFalse<T1, T2>(Boolean, T1, T2, Action<T1, T2>, Action<T1, T2>)

Executes the specified action if the given Boolean is false, otherwise it executes the specified alternative action, if one is specified.

Declaration
public static bool IfFalse<T1, T2>(this bool value, T1 parameter1, T2 parameter2, Action<T1, T2> action, Action<T1, T2> alternativeAction = null)
Parameters
Type Name Description
System.Boolean value

The Boolean to check.

T1 parameter1

The first parameter to pass to the action with gets executed.

T2 parameter2

The second parameter to pass to the action with gets executed.

System.Action<T1, T2><T1, T2> action

The action to execute if the given value is false.

System.Action<T1, T2><T1, T2> alternativeAction

The action to execute if the given value is true.>

Returns
Type Description
System.Boolean

Returns the given boolean value.

Type Parameters
Name Description
T1 The type of the first parameter.
T2 The type of the second parameter.
Exceptions
Type Condition
System.ArgumentNullException

action can not be null.

| Improve this Doc View Source

IfFalse<T1, T2, T3>(Boolean, T1, T2, T3, Action<T1, T2, T3>, Action<T1, T2, T3>)

Executes the specified action if the given Boolean is false, otherwise it executes the specified alternative action, if one is specified.

Declaration
public static bool IfFalse<T1, T2, T3>(this bool value, T1 parameter1, T2 parameter2, T3 parameter3, Action<T1, T2, T3> action, Action<T1, T2, T3> alternativeAction = null)
Parameters
Type Name Description
System.Boolean value

The Boolean to check.

T1 parameter1

The first parameter to pass to the action with gets executed.

T2 parameter2

The second parameter to pass to the action with gets executed.

T3 parameter3

The third parameter to pass to the action with gets executed.

System.Action<T1, T2, T3><T1, T2, T3> action

The action to execute if the given value is false.

System.Action<T1, T2, T3><T1, T2, T3> alternativeAction

The action to execute if the given value is true.>

Returns
Type Description
System.Boolean

Returns the given boolean value.

Type Parameters
Name Description
T1 The type of the first parameter.
T2 The type of the second parameter.
T3 The type of the third parameter.
Exceptions
Type Condition
System.ArgumentNullException

action can not be null.

| Improve this Doc View Source

IfFalse<T1, T2, T3, T4>(Boolean, T1, T2, T3, T4, Action<T1, T2, T3, T4>, Action<T1, T2, T3, T4>)

Executes the specified action if the given Boolean is false, otherwise it executes the specified alternative action, if one is specified.

Declaration
public static bool IfFalse<T1, T2, T3, T4>(this bool value, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, Action<T1, T2, T3, T4> action, Action<T1, T2, T3, T4> alternativeAction = null)
Parameters
Type Name Description
System.Boolean value

The Boolean to check.

T1 parameter1

The first parameter to pass to the action with gets executed.

T2 parameter2

The second parameter to pass to the action with gets executed.

T3 parameter3

The third parameter to pass to the action with gets executed.

T4 parameter4

The fourth parameter to pass to the action with gets executed.

System.Action<T1, T2, T3, T4><T1, T2, T3, T4> action

The action to execute if the given value is false.

System.Action<T1, T2, T3, T4><T1, T2, T3, T4> alternativeAction

The action to execute if the given value is true.>

Returns
Type Description
System.Boolean

Returns the given boolean value.

Type Parameters
Name Description
T1 The type of the first parameter.
T2 The type of the second parameter.
T3 The type of the third parameter.
T4 The type of the fourth parameter.
Exceptions
Type Condition
System.ArgumentNullException

action can not be null.

| Improve this Doc View Source

IfTrue(Boolean, Action, Action)

Executes the specified action if the given Boolean is true, otherwise it executes the specified alternative action, if one is specified.

Declaration
public static bool IfTrue(this bool value, Action action, Action alternativeAction = null)
Parameters
Type Name Description
System.Boolean value

The Boolean to check.

System.Action action

The action to execute if the given value is true.

System.Action alternativeAction

The action to execute if the given value is false.

Returns
Type Description
System.Boolean

Returns the given boolean value.

Exceptions
Type Condition
System.ArgumentNullException

action can not be null.

| Improve this Doc View Source

IfTrue<T>(Boolean, T, Action<T>, Action<T>)

Executes the specified action if the given Boolean is true, otherwise it executes the specified alternative action, if one is specified.

Declaration
public static bool IfTrue<T>(this bool value, T parameter, Action<T> action, Action<T> alternativeAction = null)
Parameters
Type Name Description
System.Boolean value

The Boolean to check.

T parameter

The parameter to pass to the action with gets executed.

System.Action<T><T> action

The action to execute if the given value is true.

System.Action<T><T> alternativeAction

The action to execute if the given value is false.

Returns
Type Description
System.Boolean

Returns the given boolean value.

Type Parameters
Name Description
T The type of the parameter.
Exceptions
Type Condition
System.ArgumentNullException

action can not be null.

| Improve this Doc View Source

IfTrue<T1, T2>(Boolean, T1, T2, Action<T1, T2>, Action<T1, T2>)

Executes the specified action if the given Boolean is true, otherwise it executes the specified alternative action, if one is specified.

Declaration
public static bool IfTrue<T1, T2>(this bool value, T1 parameter1, T2 parameter2, Action<T1, T2> action, Action<T1, T2> alternativeAction = null)
Parameters
Type Name Description
System.Boolean value

The Boolean to check.

T1 parameter1

The first parameter to pass to the action with gets executed.

T2 parameter2

The second parameter to pass to the action with gets executed.

System.Action<T1, T2><T1, T2> action

The action to execute if the given value is true.

System.Action<T1, T2><T1, T2> alternativeAction

The action to execute if the given value is false.

Returns
Type Description
System.Boolean

Returns the given boolean value.

Type Parameters
Name Description
T1 The type of the first parameter.
T2 The type of the second parameter.
Exceptions
Type Condition
System.ArgumentNullException

action can not be null.

| Improve this Doc View Source

IfTrue<T1, T2, T3>(Boolean, T1, T2, T3, Action<T1, T2, T3>, Action<T1, T2, T3>)

Executes the specified action if the given Boolean is true, otherwise it executes the specified alternative action, if one is specified.

Declaration
public static bool IfTrue<T1, T2, T3>(this bool value, T1 parameter1, T2 parameter2, T3 parameter3, Action<T1, T2, T3> action, Action<T1, T2, T3> alternativeAction = null)
Parameters
Type Name Description
System.Boolean value

The Boolean to check.

T1 parameter1

The first parameter to pass to the action with gets executed.

T2 parameter2

The second parameter to pass to the action with gets executed.

T3 parameter3

The third parameter to pass to the action with gets executed.

System.Action<T1, T2, T3><T1, T2, T3> action

The action to execute if the given value is true.

System.Action<T1, T2, T3><T1, T2, T3> alternativeAction

The action to execute if the given value is false.

Returns
Type Description
System.Boolean

Returns the given boolean value.

Type Parameters
Name Description
T1 The type of the first parameter.
T2 The type of the second parameter.
T3 The type of the third parameter.
Exceptions
Type Condition
System.ArgumentNullException

action can not be null.

| Improve this Doc View Source

IfTrue<T1, T2, T3, T4>(Boolean, T1, T2, T3, T4, Action<T1, T2, T3, T4>, Action<T1, T2, T3, T4>)

Executes the specified action if the given Boolean is true, otherwise it executes the specified alternative action, if one is specified.

Declaration
public static bool IfTrue<T1, T2, T3, T4>(this bool value, T1 parameter1, T2 parameter2, T3 parameter3, T4 parameter4, Action<T1, T2, T3, T4> action, Action<T1, T2, T3, T4> alternativeAction = null)
Parameters
Type Name Description
System.Boolean value

The Boolean to check.

T1 parameter1

The first parameter to pass to the action with gets executed.

T2 parameter2

The second parameter to pass to the action with gets executed.

T3 parameter3

The third parameter to pass to the action with gets executed.

T4 parameter4

The fourth parameter to pass to the action with gets executed.

System.Action<T1, T2, T3, T4><T1, T2, T3, T4> action

The action to execute if the given value is true.

System.Action<T1, T2, T3, T4><T1, T2, T3, T4> alternativeAction

The action to execute if the given value is false.

Returns
Type Description
System.Boolean

Returns the given boolean value.

Type Parameters
Name Description
T1 The type of the first parameter.
T2 The type of the second parameter.
T3 The type of the third parameter.
T4 The type of the fourth parameter.
Exceptions
Type Condition
System.ArgumentNullException

action can not be null.

| Improve this Doc View Source

SelectValue<T>(Boolean, T, T)

Returns the true or false value based on the given Boolean value.

Declaration
public static T SelectValue<T>(this bool value, T trueValue, T falseValue)
Parameters
Type Name Description
System.Boolean value

The Boolean to check

T trueValue

The true value to be returned if the given value is true.

T falseValue

The false value to be returned if the given value is false.

Returns
Type Description
T

The true value if the given Boolean is true, otherwise the false value.

Type Parameters
Name Description
T
  • Improve this Doc
  • View Source
Back to top Copyright © 2015-2016 Microsoft
Generated by DocFX