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

Afficher le fichier Open project: hconceicao/Castle.Facilities.NHibernateIntegration3

Méthodes publiques

Méthode 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

Méthode 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 méthode

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.
Résultat void

ConvertTo() public static méthode

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.
Résultat object

GetFieldValue() public static méthode

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

GetFieldsDictionary() public static méthode

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
Résultat IDictionary

GetFieldsWithAttribute() public static méthode

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
Résultat FieldInfoCollection

GetFieldsWithOutAttributes() public static méthode

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

GetName() public static méthode

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
Résultat string

GetNameOrEmpty() public static méthode

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
Résultat string

GetProperties() public static méthode

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

GetPropertiesDictionary() public static méthode

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
Résultat IDictionary

GetPropertyValue() public static méthode

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

GetPropertyValue() public static méthode

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

GetValue() public static méthode

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
Résultat string

HasValue() public static méthode

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
Résultat bool

IsSimpleObject() public static méthode

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
Résultat bool

IsSimpleType() public static méthode

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
Résultat bool

RemoveFromArray() public static méthode

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.
Résultat void

SetName() public static méthode

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
Résultat void