Show / Hide Table of Contents

Class AbpObjectExtensions

Extension methods for all objects.

Inheritance
System.Object
AbpObjectExtensions
Namespace: System
Assembly: Volo.Abp.Core.dll
Syntax
public static class AbpObjectExtensions : object

Methods

As<T>(Object)

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

Declaration
public static T As<T>(this object obj)

    where T : class
Parameters
Type Name Description
System.Object obj

Object to cast

Returns
Type Description
T

Casted object

Type Parameters
Name Description
T

Type to be casted

If<T>(T, Boolean, 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.

Declaration
public static T If<T>(this T obj, bool condition, Action<T> action)
Parameters
Type Name Description
T obj

An object

System.Boolean condition

A condition

Action<T> action

An action that is executed only if the condition is

true

Returns
Type Description
T

Returns the original object.

Type Parameters
Name Description
T

Type of the object

If<T>(T, Boolean, 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.

Declaration
public static T If<T>(this T obj, bool condition, Func<T, T> func)
Parameters
Type Name Description
T obj

An object

System.Boolean condition

A condition

Func<T, T> func

A function that is executed only if the condition is

true

Returns
Type Description
T

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

true
) or the original object if the condition is
false

Type Parameters
Name Description
T

Type of the object

IsIn<T>(T, T[])

Check if an item is in a list.

Declaration
public static bool IsIn<T>(this T item, params T[] list)
Parameters
Type Name Description
T item

Item to check

T[] list

List of items

Returns
Type Description
System.Boolean
Type Parameters
Name Description
T

Type of the items

To<T>(Object)

Converts given object to a value type using method.

Declaration
public static T To<T>(this object obj)

    where T : struct
Parameters
Type Name Description
System.Object obj

Object to be converted

Returns
Type Description
T

Converted object

Type Parameters
Name Description
T

Type of the target object

Back to top Powered by Volosoft