ObjectHelper Class
Namespace: PTS
Assembly: PTSframework.dll
Provides a set of static methods for object
type.
Syntax
public static class ObjectHelper
Inheritance
Methods
DebugName(Object)
Gets object's type name inclusive of namespace prefix.
Declaration
public static string DebugName(this object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to get the full type name for. |
Returns
Type | Description |
---|---|
System.String | Type name inclusive of namespace prefix. |
GetTypeCode(Object)
Gets the underlying type code of given object.
Declaration
public static TypeCode GetTypeCode(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to get the |
Returns
Type | Description |
---|---|
System.TypeCode | The code of the underlying type, or |
HasTypeSameAsOrDerivedFrom(Object, Object)
Checks whether given object is either of the same type or derived from type of another object.
Declaration
public static bool HasTypeSameAsOrDerivedFrom(object value, object other)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Object to peform the test for. |
System.Object | other | Other object that has either the same or has base type to primary object type. |
Returns
Type | Description |
---|---|
System.Boolean | If given object type is either the same or derived from other object type then |
IsBoolean(Object)
Checks whether gien object is an instance of bool
type.
Declaration
public static bool IsBoolean(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to inspect. |
Returns
Type | Description |
---|---|
System.Boolean | If given object is boolean then |
IsDateTime(Object)
Checks whether gien object is an instance of DateTime
type.
Declaration
public static bool IsDateTime(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to inspect. |
Returns
Type | Description |
---|---|
System.Boolean | If given object is |
IsIntegral(Object)
Checks wether given object is of integer value type.
Declaration
public static bool IsIntegral(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to inspect. |
Returns
Type | Description |
---|---|
System.Boolean | If the object is of integer type then |
IsNumeric(Object)
Checks wether given object is of numeric value type.
Declaration
public static bool IsNumeric(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to inspect. |
Returns
Type | Description |
---|---|
System.Boolean | If the object is of numeric value type then |
IsText(Object)
Checks wether given object is of string or char type.
Declaration
public static bool IsText(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to inspect. |
Returns
Type | Description |
---|---|
System.Boolean | If the object is of string or char type then |
ToType<TValue>(Object)
Converts given object to specified type.
Declaration
public static TValue ToType<TValue>(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Object to convert. |
Returns
Type | Description |
---|---|
TValue | Instance of the object converted to given type. |
Type Parameters
Name | Description |
---|---|
TValue | Type to convert the object to. |
ToType<TValue>(Object, Type)
Converts given object to specified type.
Declaration
public static TValue ToType<TValue>(object value, Type inputType)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Object to convert. |
System.Type | inputType | The original object type. |
Returns
Type | Description |
---|---|
TValue | Instance of the object converted to given type. |
Type Parameters
Name | Description |
---|---|
TValue | Type to convert the object to. |