Skip to main content

Extensions

Useful extensions

Assembly: ServiceStack.dll
View Source
Declaration
public static class Extensions

Methods

IsParameterExpression(LambdaExpression)

Checks if the expression is a parameter expression

View Source
Declaration
public static bool IsParameterExpression(this LambdaExpression expression)
Returns

System.Boolean

Parameters
TypeName
System.Linq.Expressions.LambdaExpressionexpression

GetMember(LambdaExpression)

Gets a MemberInfo from a member expression.

View Source
Declaration
public static MemberInfo GetMember(this LambdaExpression expression)
Returns

System.Reflection.MemberInfo

Parameters
TypeName
System.Linq.Expressions.LambdaExpressionexpression

GetMember<T, TProperty>(Expression<Func<T, TProperty>>)

Gets a MemberInfo from a member expression.

View Source
Declaration
public static MemberInfo GetMember<T, TProperty>(this Expression<Func<T, TProperty>> expression)
Returns

System.Reflection.MemberInfo

Parameters
TypeName
System.Linq.Expressions.Expression<System.Func<<T>,<TProperty>>>expression
Type Parameters
  • T
  • TProperty

SplitPascalCase(String)

Splits pascal case, so "FooBar" would become "Foo Bar"

View Source
Declaration
public static string SplitPascalCase(this string input)
Returns

System.String

Parameters
TypeName
System.Stringinput

CoerceToNonGeneric<T, TProperty>(Func<T, TProperty>)

View Source
Declaration
public static Func<object, object> CoerceToNonGeneric<T, TProperty>(this Func<T, TProperty> func)
Returns

System.Func<System.Object,System.Object>

Parameters
TypeName
System.Func<<T>,<TProperty>>func
Type Parameters
  • T
  • TProperty

CoerceToNonGeneric<T>(Func<T, Boolean>)

View Source
Declaration
public static Func<object, bool> CoerceToNonGeneric<T>(this Func<T, bool> func)
Returns

System.Func<System.Object,System.Boolean>

Parameters
TypeName
System.Func<<T>,System.Boolean>func
Type Parameters
  • T

CoerceToNonGeneric<T>(Func<T, CancellationToken, Task<Boolean>>)

View Source
Declaration
public static Func<object, CancellationToken, Task<bool>> CoerceToNonGeneric<T>(this Func<T, CancellationToken, Task<bool>> func)
Returns

System.Func<System.Object,System.Threading.CancellationToken,System.Threading.Tasks.Task<System.Boolean>>

Parameters
TypeName
System.Func<<T>,System.Threading.CancellationToken,System.Threading.Tasks.Task<System.Boolean>>func
Type Parameters
  • T

CoerceToNonGeneric<T>(Func<T, Task<Boolean>>)

View Source
Declaration
public static Func<object, Task<bool>> CoerceToNonGeneric<T>(this Func<T, Task<bool>> func)
Returns

System.Func<System.Object,System.Threading.Tasks.Task<System.Boolean>>

Parameters
TypeName
System.Func<<T>,System.Threading.Tasks.Task<System.Boolean>>func
Type Parameters
  • T

CoerceToNonGeneric<T>(Func<T, Int32>)

View Source
Declaration
public static Func<object, int> CoerceToNonGeneric<T>(this Func<T, int> func)
Returns

System.Func<System.Object,System.Int32>

Parameters
TypeName
System.Func<<T>,System.Int32>func
Type Parameters
  • T

CoerceToNonGeneric<T>(Func<T, Int64>)

View Source
Declaration
public static Func<object, long> CoerceToNonGeneric<T>(this Func<T, long> func)
Returns

System.Func<System.Object,System.Int64>

Parameters
TypeName
System.Func<<T>,System.Int64>func
Type Parameters
  • T

CoerceToNonGeneric<T>(Func<T, String>)

View Source
Declaration
public static Func<object, string> CoerceToNonGeneric<T>(this Func<T, string> func)
Returns

System.Func<System.Object,System.String>

Parameters
TypeName
System.Func<<T>,System.String>func
Type Parameters
  • T

CoerceToNonGeneric<T>(Func<T, Regex>)

View Source
Declaration
public static Func<object, Regex> CoerceToNonGeneric<T>(this Func<T, Regex> func)
Returns

System.Func<System.Object,System.Text.RegularExpressions.Regex>

Parameters
TypeName
System.Func<<T>,System.Text.RegularExpressions.Regex>func
Type Parameters
  • T

CoerceToNonGeneric<T>(Action<T>)

View Source
Declaration
public static Action<object> CoerceToNonGeneric<T>(this Action<T> action)
Returns

System.Action<System.Object>

Parameters
TypeName
System.Action<<T>>action
Type Parameters
  • T

IsAsync(IValidationContext)

Checks whether this is an asynchronous validation run.

View Source
Declaration
public static bool IsAsync(this IValidationContext ctx)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.FluentValidation.IValidationContextctx