Class ObjectExtensions
Provides object extension methods.
Inheritance
System.Object
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public static class ObjectExtensions
Methods
AsEnumerableOfOne<T>(T)
Declaration
public static IEnumerable<T> AsEnumerableOfOne<T>(this T input)
Parameters
Type | Name | Description |
---|---|---|
T | input |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> |
Type Parameters
Name | Description |
---|---|
T |
DisposeIfDisposable(Object)
Declaration
public static void DisposeIfDisposable(this object input)
Parameters
Type | Name | Description |
---|---|---|
System.Object | input |
ToDictionary<TVal>(Object, String[])
Turns object into dictionary
Declaration
public static IDictionary<string, TVal> ToDictionary<TVal>(this object o, params string[] ignoreProperties)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o | |
System.String[] | ignoreProperties | Properties to ignore |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, TVal> |
Type Parameters
Name | Description |
---|---|
TVal |
ToDictionary<T, TProperty, TVal>(T, Expression<Func<T, TProperty>>[])
Converts an object into a dictionary
Declaration
public static IDictionary<string, TVal> ToDictionary<T, TProperty, TVal>(this T o, params Expression<Func<T, TProperty>>[] ignoreProperties)
Parameters
Type | Name | Description |
---|---|---|
T | o | |
System.Linq.Expressions.Expression<System.Func<T, TProperty>>[] | ignoreProperties |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, TVal> |
Type Parameters
Name | Description |
---|---|
T | |
TProperty | |
TVal |
TryConvertTo(Object, Type)
Attempts to convert the input object to the output type.
Declaration
public static Attempt<object> TryConvertTo(this object input, Type target)
Parameters
Type | Name | Description |
---|---|---|
System.Object | input | The input. |
System.Type | target | The type to convert to |
Returns
Type | Description |
---|---|
Attempt<System.Object> | The Attempt<T> |
Remarks
This code is an optimized version of the original Umbraco method
TryConvertTo<T>(Object)
Attempts to convert the input object to the output type.
Declaration
public static Attempt<T> TryConvertTo<T>(this object input)
Parameters
Type | Name | Description |
---|---|---|
System.Object | input | The input. |
Returns
Type | Description |
---|---|
Attempt<T> | The Attempt<T> |
Type Parameters
Name | Description |
---|---|
T | The type to convert to |
Remarks
This code is an optimized version of the original Umbraco method