C# Класс Rolcore.Reflection.ObjectExtensions

Extensions for Object.
Показать файл Открыть проект

Открытые методы

Метод Описание
ChangeType ( this obj, Type toType ) : object

Use this instead of Convert.ChangeType to support Nullable<> types. Returns an Object with the specified Type of which the value is equivalent to the specified object.

CopyMatchingObjectPropertiesTo ( this source, object dest, bool shallow = false ) : void

Copies value type properties with matching names and compatible types from the current instance to the specified destination, even if the source and destination are not in the same inheritance family. Incompatible and missing properties are ignored. If both the source and the destination have a complex property, the method will recurse if shallow is false.

GetPropertiesWithAttribute ( this obj, Type attributeType, bool inherit ) : System.Reflection.PropertyInfo[]
GetPropertyValue ( this obj, string propertyName ) : object

Gets the value of a property of a given object.

IsNullableType ( this obj ) : bool

Determines if the given object is Nullable<>.

SetPropertyValue ( this obj, string propertyName, object propertyValue ) : void

Sets value of a property of a given object.

SetPropertyValues ( this obj, NameValueCollection propertyValues ) : void

Sets value of multiple properties of a given object.

Приватные методы

Метод Описание
GetMethodsWithAttribute ( this obj, Type attributeType, bool inherit ) : System.Reflection.MethodInfo[]

Описание методов

ChangeType() публичный статический Метод

Use this instead of Convert.ChangeType to support Nullable<> types. Returns an Object with the specified Type of which the value is equivalent to the specified object.
public static ChangeType ( this obj, Type toType ) : object
obj this Specifies the object for which the type should change.
toType System.Type Specifies the type to change the specified object to.
Результат object

CopyMatchingObjectPropertiesTo() публичный статический Метод

Copies value type properties with matching names and compatible types from the current instance to the specified destination, even if the source and destination are not in the same inheritance family. Incompatible and missing properties are ignored. If both the source and the destination have a complex property, the method will recurse if shallow is false.
public static CopyMatchingObjectPropertiesTo ( this source, object dest, bool shallow = false ) : void
source this Specifies the source object to copy from.
dest object Specifies the destination object to copy to.
shallow bool Specifies if the copy should be shallow.
Результат void

GetPropertiesWithAttribute() публичный статический Метод

public static GetPropertiesWithAttribute ( this obj, Type attributeType, bool inherit ) : System.Reflection.PropertyInfo[]
obj this
attributeType System.Type
inherit bool
Результат System.Reflection.PropertyInfo[]

GetPropertyValue() публичный статический Метод

Gets the value of a property of a given object.
public static GetPropertyValue ( this obj, string propertyName ) : object
obj this Specifies the object from which to retrieve the property value.
propertyName string Specifies the name of the property to be returned. This /// value can be specified using "dot syntax", e.g. "FirstProperty.SecondProperty".
Результат object

IsNullableType() публичный статический Метод

Determines if the given object is Nullable<>.
public static IsNullableType ( this obj ) : bool
obj this Specifies the object instance.
Результат bool

SetPropertyValue() публичный статический Метод

Sets value of a property of a given object.
public static SetPropertyValue ( this obj, string propertyName, object propertyValue ) : void
obj this Specifies the object on which to act.
propertyName string Specifies the name of the property to be changed. This value /// can be specified using "dot syntax", e.g. "FirstProperty.SecondProperty".
propertyValue object Specifies the new value of the property.
Результат void

SetPropertyValues() публичный статический Метод

Sets value of multiple properties of a given object.
public static SetPropertyValues ( this obj, NameValueCollection propertyValues ) : void
obj this Specifies the object on which to act.
propertyValues System.Collections.Specialized.NameValueCollection Specifies the names and values of the properties to set.
Результат void