Class ObjectExtensions
Provides extension methods for object manipulation.
Inherited Members
Namespace: mk.helpers
Assembly: mk.helpers.dll
Syntax
public static class ObjectExtensions
Methods
AsDictionary(object)
Converts an object's public properties to a dictionary.
Declaration
public static IDictionary<string, object> AsDictionary(this object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to convert. |
Returns
| Type | Description |
|---|---|
| IDictionary<string, object> | A dictionary containing the object's property names and values. |
IsDefault<T>(T)
Determines whether the specified object is the default value for its type.
Declaration
public static bool IsDefault<T>(this T obj)
Parameters
| Type | Name | Description |
|---|---|---|
| T | obj | The object to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The type of the object. |
IsIn<T>(T, params T[])
Determines whether the specified object is contained in the given set of values.
Declaration
public static bool IsIn<T>(this T obj, params T[] values)
Parameters
| Type | Name | Description |
|---|---|---|
| T | obj | The object to check. |
| T[] | values | The set of values to check against. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The type of the object. |
ToExpandoObject(object)
Converts an object into an ExpandoObject, copying all its properties. Complex types and collections are recursively converted.
Declaration
public static ExpandoObject ToExpandoObject(this object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to convert to ExpandoObject. |
Returns
| Type | Description |
|---|---|
| ExpandoObject | An ExpandoObject representing the original object's properties.
Returns |