Class Condition
- Namespace
- Cuemon
- Assembly
- Cuemon.Core.dll
Provide ways to verify conditions a generic way for countless scenarios using true/false propositions.
public sealed class Condition
- Inheritance
-
Condition
Properties
Query
Gets the singleton instance of the Condition functionality allowing for extensions methods like: Condition.Query.IsTrue()
.
public static Condition Query { get; }
Property Value
- Condition
The singleton instance of the Condition functionality.
Methods
AreEqual<T>(T, T)
Determines whether the two specified x
and y
are equal by using the default equality operator from T
.
public static bool AreEqual<T>(T x, T y)
Parameters
x
TThe first object to compare.
y
TThe second object to compare.
Returns
- Boolean
true
ifx
are equal toy
; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
AreEqual<T>(T, T, IEqualityComparer<T>)
Determines whether the two specified x
and y
are equal by using the equality operator.
public static bool AreEqual<T>(T x, T y, IEqualityComparer<T> comparer)
Parameters
x
TThe first object to compare.
y
TThe second object to compare.
comparer
IEqualityComparer<T>The IEqualityComparer<T> implementation to use when comparing
x
andy
.
Returns
- Boolean
true
ifx
are equal toy
; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
Exceptions
- ArgumentNullException
comparer
is null.
AreNotEqual<T>(T, T)
Determines whether the two specified x
and y
are different by using the default equality operator from T
.
public static bool AreNotEqual<T>(T x, T y)
Parameters
x
TThe first object to compare.
y
TThe second object to compare.
Returns
- Boolean
true
ifx
are different fromy
; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
AreNotEqual<T>(T, T, IEqualityComparer<T>)
Determines whether the two specified x
and y
are different by using the equality operator.
public static bool AreNotEqual<T>(T x, T y, IEqualityComparer<T> comparer)
Parameters
x
TThe first object to compare.
y
TThe second object to compare.
comparer
IEqualityComparer<T>The IEqualityComparer<T> implementation to use when comparing
x
andy
.
Returns
- Boolean
true
ifx
are different fromy
; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
Exceptions
- ArgumentNullException
comparer
is null.
AreNotSame<T>(T, T)
Determines whether the two specified x
object are not of the same instance as the y
object.
public static bool AreNotSame<T>(T x, T y)
Parameters
x
TThe first object to compare.
y
TThe second object to compare.
Returns
- Boolean
true
ifx
object are not of the same instance as they
object; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
AreSame<T>(T, T)
Determines whether the two specified x
object are of the same instance as the y
object.
public static bool AreSame<T>(T x, T y)
Parameters
x
TThe first object to compare.
y
TThe second object to compare.
Returns
- Boolean
true
ifx
object are of the same instance as they
object; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
FlipFlop(Boolean, Action, Action)
Invokes one of two expressions depending on the value of condition
.
public static void FlipFlop(bool condition, Action firstExpression, Action secondExpression)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked; whenfalse
, thesecondExpression
is invoked.firstExpression
ActionThe delegate that is invoked when
condition
istrue
.secondExpression
ActionThe delegate that is invoked when
condition
isfalse
.
FlipFlop<T>(Boolean, Action<T>, Action<T>, T)
Invokes one of two expressions depending on the value of condition
.
public static void FlipFlop<T>(bool condition, Action<T> firstExpression, Action<T> secondExpression, T arg)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked; whenfalse
, thesecondExpression
is invoked.firstExpression
Action<T>The delegate that is invoked when
condition
istrue
.secondExpression
Action<T>The delegate that is invoked when
condition
isfalse
.arg
TThe parameter of the delegates
firstExpression
andsecondExpression
.
Type Parameters
T
The type of the parameter of the delegates
firstExpression
andsecondExpression
.
FlipFlop<T1, T2>(Boolean, Action<T1, T2>, Action<T1, T2>, T1, T2)
Invokes one of two expressions depending on the value of condition
.
public static void FlipFlop<T1, T2>(bool condition, Action<T1, T2> firstExpression, Action<T1, T2> secondExpression, T1 arg1, T2 arg2)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked; whenfalse
, thesecondExpression
is invoked.firstExpression
Action<T1, T2>The delegate that is invoked when
condition
istrue
.secondExpression
Action<T1, T2>The delegate that is invoked when
condition
isfalse
.arg1
T1The first parameter of the delegates
firstExpression
andsecondExpression
.arg2
T2The second parameter of the delegates
firstExpression
andsecondExpression
.
Type Parameters
T1
The type of the first parameter of the delegates
firstExpression
andsecondExpression
.T2
The type of the second parameter of the delegates
firstExpression
andsecondExpression
.
FlipFlop<T1, T2, T3>(Boolean, Action<T1, T2, T3>, Action<T1, T2, T3>, T1, T2, T3)
Invokes one of two expressions depending on the value of condition
.
public static void FlipFlop<T1, T2, T3>(bool condition, Action<T1, T2, T3> firstExpression, Action<T1, T2, T3> secondExpression, T1 arg1, T2 arg2, T3 arg3)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked; whenfalse
, thesecondExpression
is invoked.firstExpression
Action<T1, T2, T3>The delegate that is invoked when
condition
istrue
.secondExpression
Action<T1, T2, T3>The delegate that is invoked when
condition
isfalse
.arg1
T1The first parameter of the delegates
firstExpression
andsecondExpression
.arg2
T2The second parameter of the delegates
firstExpression
andsecondExpression
.arg3
T3The third parameter of the delegates
firstExpression
andsecondExpression
.
Type Parameters
T1
The type of the first parameter of the delegates
firstExpression
andsecondExpression
.T2
The type of the second parameter of the delegates
firstExpression
andsecondExpression
.T3
The type of the third parameter of the delegates
firstExpression
andsecondExpression
.
FlipFlop<T1, T2, T3, T4>(Boolean, Action<T1, T2, T3, T4>, Action<T1, T2, T3, T4>, T1, T2, T3, T4)
Invokes one of two expressions depending on the value of condition
.
public static void FlipFlop<T1, T2, T3, T4>(bool condition, Action<T1, T2, T3, T4> firstExpression, Action<T1, T2, T3, T4> secondExpression, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked; whenfalse
, thesecondExpression
is invoked.firstExpression
Action<T1, T2, T3, T4>The delegate that is invoked when
condition
istrue
.secondExpression
Action<T1, T2, T3, T4>The delegate that is invoked when
condition
isfalse
.arg1
T1The first parameter of the delegates
firstExpression
andsecondExpression
.arg2
T2The second parameter of the delegates
firstExpression
andsecondExpression
.arg3
T3The third parameter of the delegates
firstExpression
andsecondExpression
.arg4
T4The fourth parameter of the delegates
firstExpression
andsecondExpression
.
Type Parameters
T1
The type of the first parameter of the delegates
firstExpression
andsecondExpression
.T2
The type of the second parameter of the delegates
firstExpression
andsecondExpression
.T3
The type of the third parameter of the delegates
firstExpression
andsecondExpression
.T4
The type of the fourth parameter of the delegates
firstExpression
andsecondExpression
.
FlipFlop<T1, T2, T3, T4, T5>(Boolean, Action<T1, T2, T3, T4, T5>, Action<T1, T2, T3, T4, T5>, T1, T2, T3, T4, T5)
Invokes one of two expressions depending on the value of condition
.
public static void FlipFlop<T1, T2, T3, T4, T5>(bool condition, Action<T1, T2, T3, T4, T5> firstExpression, Action<T1, T2, T3, T4, T5> secondExpression, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked; whenfalse
, thesecondExpression
is invoked.firstExpression
Action<T1, T2, T3, T4, T5>The delegate that is invoked when
condition
istrue
.secondExpression
Action<T1, T2, T3, T4, T5>The delegate that is invoked when
condition
isfalse
.arg1
T1The first parameter of the delegates
firstExpression
andsecondExpression
.arg2
T2The second parameter of the delegates
firstExpression
andsecondExpression
.arg3
T3The third parameter of the delegates
firstExpression
andsecondExpression
.arg4
T4The fourth parameter of the delegates
firstExpression
andsecondExpression
.arg5
T5The fifth parameter of the delegates
firstExpression
andsecondExpression
.
Type Parameters
T1
The type of the first parameter of the delegates
firstExpression
andsecondExpression
.T2
The type of the second parameter of the delegates
firstExpression
andsecondExpression
.T3
The type of the third parameter of the delegates
firstExpression
andsecondExpression
.T4
The type of the fourth parameter of the delegates
firstExpression
andsecondExpression
.T5
The type of the fifth parameter of the delegates
firstExpression
andsecondExpression
.
FlipFlopAsync(Boolean, Func<Task>, Func<Task>)
Invokes one of two expressions depending on the value of condition
.
public static Task FlipFlopAsync(bool condition, Func<Task> firstExpression, Func<Task> secondExpression)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked; whenfalse
, thesecondExpression
is invoked.firstExpression
Func<Task>The function delegate that is invoked when
condition
istrue
.secondExpression
Func<Task>The function delegate that is invoked when
condition
isfalse
.
Returns
HasConsecutiveCharacters(String, Char, Int32)
Determines whether the specified value
contains a succession character
of length
.
public static bool HasConsecutiveCharacters(string value, char character, int length = 2)
Parameters
value
StringThe value to test for consecutive characters.
character
CharThe characters to locate with the specified
length
.length
Int32The number of characters in succession.
Returns
- Boolean
true
if the specifiedvalue
contains a successioncharacter
oflength
; otherwise,false
.
HasConsecutiveCharacters(String, IEnumerable<Char>, Int32)
Determines whether the specified value
contains at least one of the succession characters
of length
.
public static bool HasConsecutiveCharacters(string value, IEnumerable<char> characters, int length = 2)
Parameters
value
StringThe value to test for consecutive characters.
characters
IEnumerable<Char>The character to locate with the specified
length
.length
Int32The number of characters in succession.
Returns
- Boolean
true
if the specifiedvalue
contains at least one of the successioncharacters
oflength
; otherwise,false
.
HasDifference(String, String, out String)
Determines whether there is a set difference between second
and first
.
public static bool HasDifference(string first, string second, out string difference)
Parameters
first
StringThe value where characters that are not also in
second
will be returned.second
StringThe value to compare with
first
.difference
StringThe set difference between
second
andfirst
or Empty if no difference.
Returns
- Boolean
true
if there is a set difference betweensecond
andfirst
; otherwisefalse
.
IsBase64(String)
Determines whether the specified value
matches a base-64 structure.
public static bool IsBase64(string value)
Parameters
value
StringThe value to test for a Base64 structure.
Returns
- Boolean
true
if the specifiedvalue
matches a base-64 structure; otherwise,false
.
IsBinaryDigits(String)
Determines whether the specified value
consists only of binary digits.
public static bool IsBinaryDigits(string value)
Parameters
value
StringThe string to verify consist only of binary digits.
Returns
- Boolean
true
if the specifiedvalue
consists only of binary digits; otherwise,false
.
IsCountableSequence(IEnumerable<Int32>)
Determines whether the specified source
is a sequence of countable integrals (hence, integrals being either incremented or decremented with the same cardinality through out the sequence).
public static bool IsCountableSequence(IEnumerable<int> source)
Parameters
source
IEnumerable<Int32>The value to test for a sequence of countable characters.
Returns
- Boolean
true
if the specifiedsource
is a sequence of countable integrals (hence, integrals being either incremented or decremented with the same cardinality through out the sequence); otherwise,false
.
IsCountableSequence(IEnumerable<Int64>)
Determines whether the specified source
is a sequence of countable integrals (hence, integrals being either incremented or decremented with the same cardinality through out the sequence).
public static bool IsCountableSequence(IEnumerable<long> source)
Parameters
source
IEnumerable<Int64>The value to test for a sequence of countable characters.
Returns
- Boolean
true
if the specifiedsource
is a sequence of countable integrals (hence, integrals being either incremented or decremented with the same cardinality through out the sequence); otherwise,false
.
IsCountableSequence(String)
Determines whether the specified value
is a sequence of countable characters (hence, characters being either incremented or decremented with the same cardinality through out the sequence).
public static bool IsCountableSequence(string value)
Parameters
value
StringThe value to test for a sequence of countable characters.
Returns
- Boolean
true
if the specifiedvalue
is a sequence of countable characters (hence, characters being either incremented or decremented with the same cardinality through out the sequence); otherwise,false
.
IsDefault<T>(T)
Determines whether the specified value
has its initial default value.
public static bool IsDefault<T>(T value)
Parameters
value
TThe object to verify has its initial default value.
Returns
- Boolean
true
if the specifiedvalue
has its initial default value; otherwise,false
.
Type Parameters
T
The type of the value.
IsEmailAddress(String)
Determines whether the specified value
has a valid format of an email address.
public static bool IsEmailAddress(string value)
Parameters
value
StringThe string to verify has a valid format of an email address.
Returns
- Boolean
true
if the specifiedvalue
has a valid format of an email address; otherwise,false
.
Remarks
In my search for the most comprehensive and up-to-date regular expression for email address validation, this was the article I choose to implement: http://blog.trojanhunter.com/2012/09/26/the-best-regex-to-validate-an-email-address/.
IsEmpty(String)
Determines whether the specified value
is empty ("").
public static bool IsEmpty(string value)
Parameters
value
StringThe string to verify is empty.
Returns
- Boolean
true
if the specifiedvalue
is empty; otherwise,false
.
IsEnum<T>(String, Action<EnumStringOptions>)
Determines whether the specified value
is valid by attempting to construct an enumeration of T
.
public static bool IsEnum<T>(string value, Action<EnumStringOptions> setup = null)
where T : struct, IConvertible
Parameters
value
StringThe String containing the name or value used to attempt to construct an Enum.
setup
Action<EnumStringOptions>The EnumStringOptions which may be configured.
Returns
- Boolean
true
if the specifiedvalue
is a valid enumeration; otherwise,false
.
Type Parameters
T
The type of the enumeration to validate.
IsEven(Int32)
Determines whether the specified value
is an even number.
public static bool IsEven(int value)
Parameters
value
Int32The value to evaluate.
Returns
- Boolean
true
if the specifiedvalue
is an even number; otherwise,false
.
IsFalse(Boolean)
Determines whether the specified value
is false
.
public static bool IsFalse(bool value)
Parameters
value
BooleanThe value to verify is
false
.
Returns
- Boolean
true
if the specifiedvalue
isfalse
; otherwise,false
.
IsFalse(Boolean, Action)
Invokes the delegate expression
when value of condition
is false
.
public static void IsFalse(bool condition, Action expression)
Parameters
condition
BooleanWhen
false
, theexpression
delegate is invoked.expression
ActionThe delegate that is invoked when
condition
isfalse
.
IsGreaterThan<T>(T, T)
Determines whether the specified x
is greater than y
.
public static bool IsGreaterThan<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe first object to compare.
y
TThe second object to compare.
Returns
- Boolean
true
ifx
is greater thany
; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
IsGreaterThanOrEqual<T>(T, T)
Determines whether the specified x
is greater than or equal to y
.
public static bool IsGreaterThanOrEqual<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe first object to compare.
y
TThe second object to compare.
Returns
- Boolean
true
ifx
is greater than or equal toy
; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
IsGuid(String)
Determines whether the specified value
has a valid format of a Guid.
public static bool IsGuid(string value)
Parameters
Returns
Remarks
This implementation only evaluates for GUID formats of: D | B | P, eg. 32 digits separated by hyphens; 32 digits separated by hyphens, enclosed in brackets and 32 digits separated by hyphens, enclosed in parentheses.
The reason not to include N, eg. 32 digits is the possible unintended GUID result of a MD5 string representation.
IsGuid(String, GuidFormats)
Determines whether the specified value
has a valid format of a Guid.
public static bool IsGuid(string value, GuidFormats format)
Parameters
value
StringThe string to verify has a valid format of a Guid.
format
GuidFormatsA bitmask comprised of one or more GuidFormats that specify how the GUID parsing is conducted.
Returns
IsHex(Char)
Determines whether the specified value
is hexadecimal.
public static bool IsHex(char value)
Parameters
value
CharThe character to verify is hexadecimal.
Returns
- Boolean
true
if the specifiedvalue
is hexadecimal; otherwise,false
.
IsHex(String)
Determines whether the specified value
is hexadecimal.
public static bool IsHex(string value)
Parameters
value
StringThe string to verify is hexadecimal.
Returns
- Boolean
true
if the specifiedvalue
is hexadecimal; otherwise,false
.
IsLowerThan<T>(T, T)
Determines whether the specified x
is lower than y
.
public static bool IsLowerThan<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe first object to compare.
y
TThe second object to compare.
Returns
- Boolean
true
ifx
is lower thany
; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
IsLowerThanOrEqual<T>(T, T)
Determines whether the specified x
is lower than or equal to y
.
public static bool IsLowerThanOrEqual<T>(T x, T y)
where T : struct, IConvertible
Parameters
x
TThe first object to compare.
y
TThe second object to compare.
Returns
- Boolean
true
ifx
is lower than or equal toy
; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
IsNotDefault<T>(T)
Determines whether the specified value
does not have its initial default value.
public static bool IsNotDefault<T>(T value)
Parameters
value
TThe object to verify does not have its initial default value.
Returns
- Boolean
true
if the specifiedvalue
does not have its initial default value; otherwise,false
.
Type Parameters
T
The type of the value.
IsNotNull<T>(T)
Determines whether the specified value
is not null.
public static bool IsNotNull<T>(T value)
Parameters
value
TThe object to verify is not null.
Returns
- Boolean
true
if the specifiedvalue
is not null; otherwise,false
.
Type Parameters
T
The type of the value.
IsNotWithinRange<T>(T, T, T)
Determines whether the specified x
is outside the range of min
and max
.
public static bool IsNotWithinRange<T>(T x, T min, T max)
where T : struct, IConvertible
Parameters
x
TThe object to compare.
min
TThe minimum value of
x
.max
TThe maximum value of
x
.
Returns
- Boolean
true
ifx
is outside the range ofmin
andmax
; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
IsNull<T>(T)
Determines whether the specified value
is null.
public static bool IsNull<T>(T value)
Parameters
value
TThe object to verify is null.
Returns
- Boolean
true
if the specifiedvalue
is null; otherwise,false
.
Type Parameters
T
The type of the value.
IsNumeric(String, NumberStyles, IFormatProvider)
Determines whether the specified value can be evaluated as a number.
public static bool IsNumeric(string value, NumberStyles styles = NumberStyles.Number, IFormatProvider provider = null)
Parameters
value
StringThe value to be evaluated.
styles
NumberStylesA bitwise combination of NumberStyles values that indicates the permitted format of
value
.provider
IFormatProviderAn IFormatProvider that supplies culture-specific formatting information about
value
.
Returns
- Boolean
true
if the specified value can be evaluated as a number; otherwise,false
.
IsOdd(Int32)
Determines whether the specified value
is an odd number.
public static bool IsOdd(int value)
Parameters
value
Int32The value to evaluate.
Returns
- Boolean
true
if the specifiedvalue
is an odd number; otherwise,false
.
IsPrime(Int32)
Determines whether the specified value
is a prime number.
public static bool IsPrime(int value)
Parameters
value
Int32The positive integer to determine whether is a prime number.
Returns
- Boolean
true
if the specifiedvalue
is a prime number; otherwise,false
.
Exceptions
- ArgumentException
value
has a value smaller than 0.
IsProtocolRelativeUrl(String, Action<ProtocolRelativeUriStringOptions>)
Determines whether the specified value
is valid by attempting to construct a URI.
public static bool IsProtocolRelativeUrl(string value, Action<ProtocolRelativeUriStringOptions> setup = null)
Parameters
value
Stringsetup
Action<ProtocolRelativeUriStringOptions>The ProtocolRelativeUriStringOptions which may be configured.
Returns
- Boolean
true
if the specifiedvalue
is a protocol relative URI; otherwise,false
.
IsTrue(Boolean)
Determines whether the specified value
is true
.
public static bool IsTrue(bool value)
Parameters
value
BooleanThe value to verify is
true
.
Returns
- Boolean
true
if the specifiedvalue
istrue
; otherwise,false
.
IsTrue(Boolean, Action)
Invokes the delegate expression
when value of condition
is true
.
public static void IsTrue(bool condition, Action expression)
Parameters
condition
BooleanWhen
true
, theexpression
delegate is invoked.expression
ActionThe delegate that is invoked when
condition
istrue
.
IsUri(String, Action<UriStringOptions>)
Determines whether the specified value
is valid by attempting to construct a URI.
public static bool IsUri(string value, Action<UriStringOptions> setup = null)
Parameters
value
Stringsetup
Action<UriStringOptions>The UriStringOptions which may be configured.
Returns
- Boolean
true
if the specifiedvalue
is a valid URI; otherwise,false
.
IsWhiteSpace(String)
Determines whether the specified value
consist only of white-space characters.
public static bool IsWhiteSpace(string value)
Parameters
value
StringThe string to verify consist only of white-space characters.
Returns
- Boolean
true
if the specifiedvalue
consist only of white-space characters; otherwise,false
.
IsWithinRange<T>(T, T, T)
Determines whether the specified x
is within range of min
and max
.
public static bool IsWithinRange<T>(T x, T min, T max)
where T : struct, IConvertible
Parameters
x
TThe object to compare.
min
TThe minimum value of
x
.max
TThe maximum value of
x
.
Returns
- Boolean
true
ifx
is within range ofmin
andmax
; otherwisefalse
.
Type Parameters
T
The type of objects to compare.
TernaryIf<TResult>(Boolean, Func<TResult>, Func<TResult>)
Returns one of two values depending on the value of condition
.
public static TResult TernaryIf<TResult>(bool condition, Func<TResult> firstExpression, Func<TResult> secondExpression)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked and becomes the result; whenfalse
, thesecondExpression
is invoked and becomes the result.firstExpression
Func<TResult>The function delegate that is invoked when
condition
istrue
.secondExpression
Func<TResult>The function delegate that is invoked when
condition
isfalse
.
Returns
- TResult
The result of either function delegate
firstExpression
or function delegatesecondExpression
.
Type Parameters
TResult
The type of the result.
TernaryIf<T, TResult>(Boolean, Func<T, TResult>, Func<T, TResult>, T)
Returns one of two values depending on the value of condition
.
public static TResult TernaryIf<T, TResult>(bool condition, Func<T, TResult> firstExpression, Func<T, TResult> secondExpression, T arg)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked and becomes the result; whenfalse
, thesecondExpression
is invoked and becomes the result.firstExpression
Func<T, TResult>The function delegate that is invoked when
condition
istrue
.secondExpression
Func<T, TResult>The function delegate that is invoked when
condition
isfalse
.arg
TThe parameter of the function delegates
firstExpression
andsecondExpression
.
Returns
- TResult
The result of either function delegate
firstExpression
or function delegatesecondExpression
.
Type Parameters
T
The type of the parameter of the function delegates
firstExpression
andsecondExpression
.TResult
The type of the result.
TernaryIf<T1, T2, TResult>(Boolean, Func<T1, T2, TResult>, Func<T1, T2, TResult>, T1, T2)
Returns one of two values depending on the value of condition
.
public static TResult TernaryIf<T1, T2, TResult>(bool condition, Func<T1, T2, TResult> firstExpression, Func<T1, T2, TResult> secondExpression, T1 arg1, T2 arg2)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked and becomes the result; whenfalse
, thesecondExpression
is invoked and becomes the result.firstExpression
Func<T1, T2, TResult>The function delegate that is invoked when
condition
istrue
.secondExpression
Func<T1, T2, TResult>The function delegate that is invoked when
condition
isfalse
.arg1
T1The first parameter of the function delegates
firstExpression
andsecondExpression
.arg2
T2The second parameter of the function delegates
firstExpression
andsecondExpression
.
Returns
- TResult
The result of either function delegate
firstExpression
or function delegatesecondExpression
.
Type Parameters
T1
The type of the first parameter of the function delegates
firstExpression
andsecondExpression
.T2
The type of the second parameter of the function delegates
firstExpression
andsecondExpression
.TResult
The type of the result.
TernaryIf<T1, T2, T3, TResult>(Boolean, Func<T1, T2, T3, TResult>, Func<T1, T2, T3, TResult>, T1, T2, T3)
Returns one of two values depending on the value of condition
.
public static TResult TernaryIf<T1, T2, T3, TResult>(bool condition, Func<T1, T2, T3, TResult> firstExpression, Func<T1, T2, T3, TResult> secondExpression, T1 arg1, T2 arg2, T3 arg3)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked and becomes the result; whenfalse
, thesecondExpression
is invoked and becomes the result.firstExpression
Func<T1, T2, T3, TResult>The function delegate that is invoked when
condition
istrue
.secondExpression
Func<T1, T2, T3, TResult>The function delegate that is invoked when
condition
isfalse
.arg1
T1The first parameter of the function delegates
firstExpression
andsecondExpression
.arg2
T2The second parameter of the function delegates
firstExpression
andsecondExpression
.arg3
T3The third parameter of the function delegates
firstExpression
andsecondExpression
.
Returns
- TResult
The result of either function delegate
firstExpression
or function delegatesecondExpression
.
Type Parameters
T1
The type of the first parameter of the function delegates
firstExpression
andsecondExpression
.T2
The type of the second parameter of the function delegates
firstExpression
andsecondExpression
.T3
The type of the third parameter of the function delegates
firstExpression
andsecondExpression
.TResult
The type of the result.
TernaryIf<T1, T2, T3, T4, TResult>(Boolean, Func<T1, T2, T3, T4, TResult>, Func<T1, T2, T3, T4, TResult>, T1, T2, T3, T4)
Returns one of two values depending on the value of condition
.
public static TResult TernaryIf<T1, T2, T3, T4, TResult>(bool condition, Func<T1, T2, T3, T4, TResult> firstExpression, Func<T1, T2, T3, T4, TResult> secondExpression, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked and becomes the result; whenfalse
, thesecondExpression
is invoked and becomes the result.firstExpression
Func<T1, T2, T3, T4, TResult>The function delegate that is invoked when
condition
istrue
.secondExpression
Func<T1, T2, T3, T4, TResult>The function delegate that is invoked when
condition
isfalse
.arg1
T1The first parameter of the function delegates
firstExpression
andsecondExpression
.arg2
T2The second parameter of the function delegates
firstExpression
andsecondExpression
.arg3
T3The third parameter of the function delegates
firstExpression
andsecondExpression
.arg4
T4The fourth parameter of the function delegates
firstExpression
andsecondExpression
.
Returns
- TResult
The result of either function delegate
firstExpression
or function delegatesecondExpression
.
Type Parameters
T1
The type of the first parameter of the function delegates
firstExpression
andsecondExpression
.T2
The type of the second parameter of the function delegates
firstExpression
andsecondExpression
.T3
The type of the third parameter of the function delegates
firstExpression
andsecondExpression
.T4
The type of the fourth parameter of the function delegates
firstExpression
andsecondExpression
.TResult
The type of the result.
TernaryIf<T1, T2, T3, T4, T5, TResult>(Boolean, Func<T1, T2, T3, T4, T5, TResult>, Func<T1, T2, T3, T4, T5, TResult>, T1, T2, T3, T4, T5)
Returns one of two values depending on the value of condition
.
public static TResult TernaryIf<T1, T2, T3, T4, T5, TResult>(bool condition, Func<T1, T2, T3, T4, T5, TResult> firstExpression, Func<T1, T2, T3, T4, T5, TResult> secondExpression, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
Parameters
condition
BooleanWhen
true
, thefirstExpression
is invoked and becomes the result; whenfalse
, thesecondExpression
is invoked and becomes the result.firstExpression
Func<T1, T2, T3, T4, T5, TResult>The function delegate that is invoked when
condition
istrue
.secondExpression
Func<T1, T2, T3, T4, T5, TResult>The function delegate that is invoked when
condition
isfalse
.arg1
T1The first parameter of the function delegates
firstExpression
andsecondExpression
.arg2
T2The second parameter of the function delegates
firstExpression
andsecondExpression
.arg3
T3The third parameter of the function delegates
firstExpression
andsecondExpression
.arg4
T4The fourth parameter of the function delegates
firstExpression
andsecondExpression
.arg5
T5The fifth parameter of the function delegates
firstExpression
andsecondExpression
.
Returns
- TResult
The result of either function delegate
firstExpression
or function delegatesecondExpression
.
Type Parameters
T1
The type of the first parameter of the function delegates
firstExpression
andsecondExpression
.T2
The type of the second parameter of the function delegates
firstExpression
andsecondExpression
.T3
The type of the third parameter of the function delegates
firstExpression
andsecondExpression
.T4
The type of the fourth parameter of the function delegates
firstExpression
andsecondExpression
.T5
The type of the fifth parameter of the function delegates
firstExpression
andsecondExpression
.TResult
The type of the result.