C# Class Castle.Facilities.NHibernateIntegration.Util.ReflectionUtil

Show file Open project: hconceicao/Castle.Facilities.NHibernateIntegration3

Public Methods

Method Description
AddToArray ( FieldInfo field, object instance, object val ) : void

Adds to array.

ConvertTo ( string text, Type type ) : object

Converts from string to the type. Can covert from string, enums booleans, bytes, int32 and datetime

GetFieldValue ( object obj, FieldInfo field ) : object

Gets the field value from object, and return

GetFieldsDictionary ( object obj ) : IDictionary

Gets the fields names and values. The keys holds the names of the fields. The values hold the value of the field if it's a simple type, or the name of the field's type.

GetFieldsWithAttribute ( Type type, Type attribute ) : FieldInfoCollection

Gets all the fields from the object's type with specified attribute

GetFieldsWithOutAttributes ( Type type ) : FieldInfoCollection

Gets all the fields WITHOUT ANY of the specified attributes.

GetName ( object obj ) : string

Gets the name of an object. The name of the object is it's type name or the value of its Name property or field

GetNameOrEmpty ( object obj ) : string

Gets the value of a property or field name in the object. Or return empty string if there aren't any.

GetProperties ( object obj ) : System.Reflection.PropertyInfo[]

Gets the properties.

GetPropertiesDictionary ( object obj ) : IDictionary

Gets the readable (non indexed) properties names and values. The keys holds the names of the properties. The values are the values of the properties

GetPropertyValue ( PropertyInfo property, object obj ) : object

Gets the property value.

GetPropertyValue ( object obj, string property ) : object

Gets the property value.

GetValue ( object obj ) : string

Gets the value of the object, if the object is simple, the returned string is the object ToString(), otherwise, it's the object name (if it has one) or the object type.

HasValue ( object value ) : bool

An object has value if it's not null, an collection containing elements and a non-empty string

IsSimpleObject ( object obj ) : bool

Determines whether the object is simple. An object is simple if its type is simple or if it's null.

IsSimpleType ( Type type ) : bool

Determines whether type is simple enough to need just ToString() to show its state. (string,int, bool, enums are simple. Anything else is false.

RemoveFromArray ( FieldInfo field, object instance, int index ) : void

Removes from array.

SetName ( object obj, string name ) : void

Sets the name property or value of an object to the value of name. Does nothing if the object doesn't have any fields or properties named 'name'

Private Methods

Method Description
GetField ( object obj, string field ) : FieldInfo

Gets the FieldInfo thus named

GetProperty ( object obj, string property ) : PropertyInfo

Gets the PropertyInfo thus named.

PropertyHasValue ( object obj, PropertyInfo prop ) : bool

Check if the property is not null and can be read and is no indexed. This is done to know if it can be read safely.

Method Details

AddToArray() public static method

Adds to array.
public static AddToArray ( FieldInfo field, object instance, object val ) : void
field System.Reflection.FieldInfo The field.
instance object The instance.
val object The val.
return void

ConvertTo() public static method

Converts from string to the type. Can covert from string, enums booleans, bytes, int32 and datetime
public static ConvertTo ( string text, Type type ) : object
text string Text.
type System.Type Type.
return object

GetFieldValue() public static method

Gets the field value from object, and return
public static GetFieldValue ( object obj, FieldInfo field ) : object
obj object
field System.Reflection.FieldInfo
return object

GetFieldsDictionary() public static method

Gets the fields names and values. The keys holds the names of the fields. The values hold the value of the field if it's a simple type, or the name of the field's type.
public static GetFieldsDictionary ( object obj ) : IDictionary
obj object
return IDictionary

GetFieldsWithAttribute() public static method

Gets all the fields from the object's type with specified attribute
public static GetFieldsWithAttribute ( Type type, Type attribute ) : FieldInfoCollection
type System.Type
attribute System.Type
return FieldInfoCollection

GetFieldsWithOutAttributes() public static method

Gets all the fields WITHOUT ANY of the specified attributes.
public static GetFieldsWithOutAttributes ( Type type ) : FieldInfoCollection
type System.Type
return FieldInfoCollection

GetName() public static method

Gets the name of an object. The name of the object is it's type name or the value of its Name property or field
public static GetName ( object obj ) : string
obj object
return string

GetNameOrEmpty() public static method

Gets the value of a property or field name in the object. Or return empty string if there aren't any.
public static GetNameOrEmpty ( object obj ) : string
obj object
return string

GetProperties() public static method

Gets the properties.
public static GetProperties ( object obj ) : System.Reflection.PropertyInfo[]
obj object The obj.
return System.Reflection.PropertyInfo[]

GetPropertiesDictionary() public static method

Gets the readable (non indexed) properties names and values. The keys holds the names of the properties. The values are the values of the properties
public static GetPropertiesDictionary ( object obj ) : IDictionary
obj object
return IDictionary

GetPropertyValue() public static method

Gets the property value.
public static GetPropertyValue ( PropertyInfo property, object obj ) : object
property System.Reflection.PropertyInfo The property.
obj object The obj.
return object

GetPropertyValue() public static method

Gets the property value.
public static GetPropertyValue ( object obj, string property ) : object
obj object obj.
property string Property.
return object

GetValue() public static method

Gets the value of the object, if the object is simple, the returned string is the object ToString(), otherwise, it's the object name (if it has one) or the object type.
public static GetValue ( object obj ) : string
obj object
return string

HasValue() public static method

An object has value if it's not null, an collection containing elements and a non-empty string
public static HasValue ( object value ) : bool
value object
return bool

IsSimpleObject() public static method

Determines whether the object is simple. An object is simple if its type is simple or if it's null.
public static IsSimpleObject ( object obj ) : bool
obj object
return bool

IsSimpleType() public static method

Determines whether type is simple enough to need just ToString() to show its state. (string,int, bool, enums are simple. Anything else is false.
public static IsSimpleType ( Type type ) : bool
type System.Type
return bool

RemoveFromArray() public static method

Removes from array.
public static RemoveFromArray ( FieldInfo field, object instance, int index ) : void
field System.Reflection.FieldInfo The field.
instance object The instance.
index int The index.
return void

SetName() public static method

Sets the name property or value of an object to the value of name. Does nothing if the object doesn't have any fields or properties named 'name'
public static SetName ( object obj, string name ) : void
obj object
name string
return void