Table of Contents

Class AbpObjectExtensions

Namespace
System
Assembly
Volo.Abp.Core.dll

Extension methods for all objects.

public static class AbpObjectExtensions
Inheritance
AbpObjectExtensions
Inherited Members

Methods

As<T>(object)

Used to simplify and beautify casting an object to a type.

public static T As<T>(this object obj) where T : class

Parameters

obj object

Object to cast

Returns

T

Casted object

Type Parameters

T

Type to be casted

If<T>(T, bool, Action<T>)

Can be used to conditionally perform an action on an object and return the original object. It is useful for chained calls on the object.

public static T If<T>(this T obj, bool condition, Action<T> action)

Parameters

obj T

An object

condition bool

A condition

action Action<T>

An action that is executed only if the condition is

true

Returns

T

Returns the original object.

Type Parameters

T

Type of the object

If<T>(T, bool, Func<T, T>)

Can be used to conditionally perform a function on an object and return the modified or the original object. It is useful for chained calls.

public static T If<T>(this T obj, bool condition, Func<T, T> func)

Parameters

obj T

An object

condition bool

A condition

func Func<T, T>

A function that is executed only if the condition is

true

Returns

T

Returns the modified object (by the func if the condition is

true
) or the original object if the condition is
false

Type Parameters

T

Type of the object

IsIn<T>(T, IEnumerable<T>)

Check if an item is in the given enumerable.

public static bool IsIn<T>(this T item, IEnumerable<T> items)

Parameters

item T

Item to check

items IEnumerable<T>

Items

Returns

bool

Type Parameters

T

Type of the items

IsIn<T>(T, params T[])

Check if an item is in a list.

public static bool IsIn<T>(this T item, params T[] list)

Parameters

item T

Item to check

list T[]

List of items

Returns

bool

Type Parameters

T

Type of the items

To<T>(object)

Converts given object to a value type using ChangeType(object, Type) method.

public static T To<T>(this object obj) where T : struct

Parameters

obj object

Object to be converted

Returns

T

Converted object

Type Parameters

T

Type of the target object