Class ObjectExtensions
Provides extension methods to all objects.
Inheritance
System.Object
ObjectExtensions
Namespace:MyTested.AspNetCore.Mvc.Utilities.Extensions
Assembly:MyTested.AspNetCore.Mvc.Abstractions.dll
Syntax
public static class ObjectExtensions
Methods
| Improve this Doc View SourceAsDynamic(Object)
Returns the provided object casted as dynamic type.
Declaration
public static dynamic AsDynamic(this object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Object | Object of dynamic type. |
GetErrorMessageName(Object, Boolean, String)
Calls ToString on the provided object and returns the value. If the object is null, the provided optional name is returned.
Declaration
public static string GetErrorMessageName(this object obj, bool includeQuotes = true, string nullCaseName = "null")
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Object to get error message name. |
System.Boolean | includeQuotes | Whether to include quotes around the error message name. |
System.String | nullCaseName | Name to return in case of null object. |
Returns
Type | Description |
---|---|
System.String | Error message name. |
GetName(Object)
Gets friendly type name of object. Useful for generic types.
Declaration
public static string GetName(this object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Object to get friendly name from. |
Returns
Type | Description |
---|---|
System.String | Friendly name as string. |
ToObjectValueDictionary(Object)
Declaration
public static IDictionary<string, object> ToObjectValueDictionary(this object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Object> |
ToStringValueDictionary(Object)
Declaration
public static IDictionary<string, string> ToStringValueDictionary(this object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.String> |
TryCastTo<T>(Object)
Declaration
public static T TryCastTo<T>(this object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |